Sieve of Eratosthenes: Difference between revisions
→{{header|Quackery}}: isprime now returns false if passed an argument larger than that passed to eratosthenes
(→{{header|Quackery}}: isprime now returns false if passed an argument larger than that passed to eratosthenes) |
|||
Line 15,187:
number on the primes ancillary stack is set.
Initially all the bits are set except for 0 and 1,
which are not prime numbers by definition.
"eratosthenes" unsets all bits above those specified
by it's argument. )
[ bit ~
Line 15,194 ⟶ 15,196:
[ bit primes share & 0 != ] is isprime ( n --> b )
[ dup dup sqrt times
[ i^ 1+
dup isprime if
[ dup 2 **
[ dup -composite
over +
rot 2dup >
dip unrot until ]
drop ]
drop ]
drop
drop ] is eratosthenes ( n --> )▼
1+ bit 1 -
primes take &
100 eratosthenes
|