Handbook
Glossary
next-prime ( n -- p )
Prime numbers
Prev:
prime? ( n -- ? )
Next:
primes-upto ( n -- seq )
Vocabulary
math
.
primes
Inputs
n
an
integer
Outputs
p
a prime number
Word description
Return the next prime number greater than
n
.
See also
prime?
Definition
USING:
kernel
math
math.bitwise
;
IN:
math.primes
:
next-prime
( n -- p )
dup
2
<
[
drop
2
]
[
next-odd
[
dup
prime?
]
[
2
+
]
until
]
if
;
foldable
flushable