Handbook
Glossary
prime? ( n -- ? )
Prime numbers
Next:
next-prime ( n -- p )
Vocabulary
math
.
primes
Inputs
n
an
integer
Outputs
?
a
boolean
Word description
Test if an integer is a prime number.
See also
next-prime
Definition
USING:
combinators
kernel
math
math.primes.private
sequences
;
IN:
math.primes
:
prime?
( n -- ? )
dup
integer?
[
{
{
[
dup
7
<
]
[
{
2 3 5
}
member?
]
}
{
[
dup
simple?
]
[
drop
f
]
}
[
(prime?)
]
}
cond
]
[
drop
f
]
if
;
foldable
flushable