Handbook
Glossary
safe-prime? ( q -- ? )
Safe prime numbers
Next:
next-safe-prime ( n -- q )
Vocabulary
math
.
primes
.
safe
Inputs
q
an
integer
Outputs
?
a
boolean
Word description
Tests whether the number is a safe prime. A safe prime
p
must be prime, as must
(p - 1) / 2
.
Definition
USING:
combinators.short-circuit
math
math.primes
;
IN:
math.primes.safe
:
safe-prime?
( q -- ? )
{
[
prime?
]
[
1
-
2
/
prime?
]
}
1&&
;