Handbook
Glossary
(miller-rabin) ( n trials -- ? )
Vocabulary
math
.
primes
.
miller-rabin
.
private
Inputs
n
an
object
trials
an
object
Outputs
?
an
object
Definition
USING:
kernel
math
math.functions
random
ranges
sequences
;
IN:
math.primes.miller-rabin.private
::
(miller-rabin)
( n trials -- ? )
n 1
-
:>
n-1 n-1
factor-2s
:>
( r s ) 0
:>
a! trials
<iota>
[
drop
2 n 2
-
[a..b]
random
a! a s n
^mod
1
=
[
f
]
[
r
<iota>
[
2^
s
*
a
swap
n
^mod
n-1
=
]
none?
]
if
]
none?
;