anonymous
  • anonymous
Just joined no experience before so this exercise is doing my head in. Here is what I have and it just loops. Any help would be greatly appreciated. n=int (1) ##This will act as counter s=int (3) ## A number to get us started divs=int (2) ## Integers I will diving with. while n<5: ## to ensure I kill at 1000th prime while s%2 != 0: ## If its an even number it isnt prime while divs
MIT 6.00 Intro Computer Science (OCW)
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.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions.

anonymous
  • anonymous
Just joined no experience before so this exercise is doing my head in. Here is what I have and it just loops. Any help would be greatly appreciated. n=int (1) ##This will act as counter s=int (3) ## A number to get us started divs=int (2) ## Integers I will diving with. while n<5: ## to ensure I kill at 1000th prime while s%2 != 0: ## If its an even number it isnt prime while divs
MIT 6.00 Intro Computer Science (OCW)
katieb
  • katieb
See more answers at brainly.com
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.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
else: n= n+1 else: s = s+1 else: print s
anonymous
  • anonymous
I'm not sure I understand what you're trying to do with the while ... else ... bits. I very rarely find a use case for while else, and in your specific case, I don't see how the innermost while loop will end since 3%n for every N in the natural numbers will never = 0. Try restricting yourself to only using else for if statements, and I think you'll have an easier time wrapping your brain around the task.
anonymous
  • anonymous
I need the slap face smiley!! Thank you for your patience.

Looking for something else?

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

More answers

anonymous
  • anonymous
Also using a pastebin site like dpaste.com can make it easier to see/edit your code to get help.
anonymous
  • anonymous
You might want to also limit the numerator to odd numbers, and the divisors to a certain value less than the numerator, otherwise it will do the calculation up to the numerator -1, which is not needed. See this website for a good explanation. http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes

Looking for something else?

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