Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,30 @@
|
|||
import util.rnd
|
||||
|
||||
def isProbablyPrimeMillerRabin( n, k ) =
|
||||
d = n - 1
|
||||
s = 0
|
||||
|
||||
while 2|d
|
||||
s++
|
||||
d /= 2
|
||||
|
||||
repeat k
|
||||
a = rnd( 2, n )
|
||||
x = a^d mod n
|
||||
|
||||
if x == 1 or x == n - 1 then continue
|
||||
|
||||
repeat s - 1
|
||||
x = x^2 mod n
|
||||
|
||||
if x == 1 then return false
|
||||
|
||||
if x == n - 1 then break
|
||||
else
|
||||
return false
|
||||
|
||||
true
|
||||
|
||||
for i <- 3..100
|
||||
if isProbablyPrimeMillerRabin( i, 5 )
|
||||
println( i )
|
||||
Loading…
Add table
Add a link
Reference in a new issue