Finding prime numbers

kyosohma at gmail.com kyosohma at gmail.com
Wed Sep 19 14:17:01 EDT 2007


On Sep 19, 12:15 pm, "Shawn Milochik" <Sh... at Milochik.com> wrote:
> Okay, I caught one bug already myself:
>
>  for y in range(3,(math.sqrt(x) + 1)):
>
> should be
>
> for y in range(3,(int(math.sqrt(x)) + 1)):

If you'd just search the archives, you would have found this:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/b134b2235e9c19a6/34857fb0b0b2a4b5?lnk=gst&q=prime+number&rnum=1#34857fb0b0b2a4b5

And Google has many hits. Here's one example:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/366178

Mike




More information about the Python-list mailing list