returning none when it should be returning a list?
danb_83 at yahoo.com
Mon May 1 11:06:24 CEST 2006
Edward Elliott wrote:
[in reponse to some prime-number code]
> 5. you can do better than checking every odd number (next+2) to find the
> next prime, but I'm too tired to look into it right now. it may require
> more complex machinery.
You only need to check the prime numbers up to sqrt(n). If you're
calculating primes in sequential order, this is easy. Otherwise, you
can remove a third of the odd divisors by considering only odd numbers
of the form 6k±1 (because 6k±3 is divisible by 3).
i = 6
yield i - 1
yield i + 1
i += 6
More information about the Python-list