[docs] Prime num bug

Sandro Tosi sandro.tosi at gmail.com
Thu Feb 17 21:33:07 CET 2011


Hi Jon,

On Wed, Feb 9, 2011 at 05:21, Jon <jongoldsteinis at yahoo.com> wrote:
> Hi there
>
> The prime number function in 4.4 breaks and continue statements is wrong.

Care to explain why? I can see it works as expected:

$ ./python
Python 3.2rc3+ (py3k, Feb 17 2011, 21:31:25)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> for n in range(2, 10):
...     for x in range(2, n):
...         if n % x == 0:
...             print(n, 'equals', x, '*', n//x)
...             break
...     else:
...         # loop fell through without finding a factor
...         print(n, 'is a prime number')
...
2 is a prime number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3

Regards,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi


More information about the docs mailing list