anonymous
  • anonymous
I'm having trouble with problem 2 in problem set 1.so far i did this & getting an error:: from math import * count = 0 i = 1 limitnum = raw_input('Enter the limit of the range') for i in range(2,limitnum): if limitnum/i == 0: break; else: count= count+ log(i+1) i = i + 1 print log(i)
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
maitre_kaio
  • maitre_kaio
You probably want to use % (modulo), not / (integer division) For example: 13 / 5 = 2 and 13 % 5 = 3
anonymous
  • anonymous
Were you able to solve Problem 1 successfully? If so, please post the code. Problem 2 builds on Problem 1 and requires only a slight modification.
anonymous
  • anonymous
problem 1: prime = 0 number = 1 while prime < 1000: number = number + 1 # starting from 2 # testing if the number is prime or not divisor = 2 numberIsPrime = True while divisor*divisor <= number: if number % divisor == 0: numberIsPrime = False break divisor = divisor + 1 # found one? if numberIsPrime: prime = prime + 1 print number

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
problem 2 is giving an error:File "C:\Python25\ps1b.py", line 11, in for i in range(2,limitnum): TypeError: range() integer end argument expected, got str. still can't slove.
anonymous
  • anonymous
@maitre_kaio:thanx for highlighting the logical error,but i think it's giving me a syntax error.isn't it??i have post it above.

Looking for something else?

Not the answer you are looking for? Search for more explanations.