Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
F isProbablePrime(n, k = 10)
|
||||
I n < 2 | n % 2 == 0
|
||||
R n == 2
|
||||
|
||||
V d = n - 1
|
||||
V s = 0
|
||||
L d % 2 == 0
|
||||
d I/= 2
|
||||
s++
|
||||
|
||||
assert(2 ^ s * d == n - 1)
|
||||
|
||||
L 0 .< k
|
||||
V a = random:(2 .< n)
|
||||
V x = pow(a, d, n)
|
||||
I x == 1 | x == n - 1
|
||||
L.continue
|
||||
L 0 .< s - 1
|
||||
x = pow(x, 2, n)
|
||||
I x == 1
|
||||
R 0B
|
||||
I x == n - 1
|
||||
L.break
|
||||
L.was_no_break
|
||||
R 0B
|
||||
|
||||
R 1B
|
||||
|
||||
print((2..29).filter(x -> isProbablePrime(x)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue