• anonymous
I seem to have got myself into a endless loop on the finding the 100th prime number project and cant see what is causing it any help anyone could give me would be appreciated. Here is my code. primeCount = 2 primeCheck = 3.0; divisor = 2; result = 0; while primeCount <= 1000: while divisor < primeCheck/2: result = primeCheck % divisor; if result == 0: primeCount = primeCount + 1; primeCheck = primeCheck + 2; else: divisor = divisor + 1; print "The 1000th prime number is ", primeCheck, ".";
MIT 6.00 Intro Computer Science (OCW)
  • schrodinger
I got my questions answered at in under 10 minutes. Go to now for free help!
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


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

  • anonymous
I might be reading this wrong, but you never increment divisor in the second while loop. So once you get primeCheck up to 5 it can't escape that loop. The rest seems ok.
  • anonymous
The logic here is missing something. Try steping through the code one line at a time with a paper/pencil, and at each line write the current values for primeCount, divisor, primeCheck, and result. Also you can try adding print statements to see where your code is getting stuck.

Looking for something else?

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