Anonymous user
Sieve of Eratosthenes: Difference between revisions
m
→Fast infinite generator using a wheel: corrected a typeo of 2/3/5/7/1/13/17 to 2/3/5/7/11/13/17.
GordonBGood (talk | contribs) (→Fast infinite generator using a wheel: added a very large wheel with links to ideone.com) |
m (→Fast infinite generator using a wheel: corrected a typeo of 2/3/5/7/1/13/17 to 2/3/5/7/11/13/17.) |
||
Line 3,730:
for p, pi in wheel_prime_pairs(): yield p # strip out indexes</lang>
Further gains of about 1.5 times in speed can be made using the same code by only changing the tables and a few constants for a further constant factor gain of about 1.5 times in speed by using a 2/3/5/7/
<lang python>def primes():
whlPrms = [2,3,5,7,11,13,17] # base wheel primes
|