[Python-ideas] Is this PEP-able? for X in ListY while conditionZ:
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Jul 3 07:52:38 CEST 2013
Daniel Robinson wrote:
> That cofactor would have to have a prime factor less than sqrt(n).
<facepalm>
You're right, of course. I feel suitably enfoolished.
</facepalm>
But there is a slight error in the second implementation:
if all(n % p for p in takewhile(lambda p: p**2 < n, primes_seen)):
should be
if all(n % p for p in takewhile(lambda p: p**2 <= n, primes_seen)):
otherwise it thinks that perfect squares are primes.
--
Greg
More information about the Python-ideas
mailing list