Factor Documentation
|
Home
|
Glossary
|
Search
factorcode.org
sieve ( n -- arr )
Vocabulary
math.primes.erato
Inputs and outputs
n
an
integer
arr
a
byte-array
Word description
Apply Eratostene sieve up to
n
.
n
must be greater than 1. Primality can then be tested using
marked-prime?
.
Definition
USING:
kernel
math.functions
math.primes.erato.private
math.ranges
sequences
;
IN:
math.primes.erato
:
sieve
( n -- arr )
init-sieve
[
2
swap
upper-bound
sqrt
[a,b]
]
keep
[
[
unmark-multiples
]
curry
each
]
keep
;