Sieve of Eratosthenes: Difference between revisions
Content deleted Content added
Corrected limit in loop to set "composites[c]" to true. Changed "*%" to "*". |
|||
Line 11,837: | Line 11,837: | ||
for n in 2 .. sqrtLimit: # cull to square root of limit |
for n in 2 .. sqrtLimit: # cull to square root of limit |
||
if not composites[n]: # if prime -> cull its composites |
if not composites[n]: # if prime -> cull its composites |
||
for c in countup(n * |
for c in countup(n * n, limit, n): # start at ``n`` squared |
||
composites[c] = true |
composites[c] = true |
||
for n in 2 .. limit: # separate iteration over results |
for n in 2 .. limit: # separate iteration over results |