![](https://secure.gravatar.com/avatar/72ee673975357d43d79069ac1cd6abda.jpg?s=120&d=mm&r=g)
July 3, 2013
5:52 a.m.
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