Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-11-09 14:05:01 +01:00
parent d2816f13ea
commit 00225c1d54
Signed by: y0rune
GPG Key ID: F204C385F57EB348

View File

@ -113,20 +113,20 @@ def primalityTest(n)
return true return true
end end
counter = rand(n/2..n) counter = rand(3..n)
while (counter != 0) do while (counter != 0) do
b = rand(2..n) b = rand(2..n-2) # Tez dziala n-1
if betterExponentiation(b,n-1,n) != 1 then if betterExponentiation(b,n-1,n) != 1 then
return false return false
end end
counter = counter + 1 counter = counter - 1
end end
return true return true
end end
#1 #puts random_gen_Zn(50,3) #1 puts random_gen_Zn(50,3)
#2 #puts reciprocal_Phi_p(5,7) #2 puts reciprocal_Phi_p(5,7)
#3 #puts betterExponentiation(24637864786278436723,10,3) #3 puts betterExponentiation(24637864786278436723,10,3)
#4 #puts remSqEuler(5,13) #4 puts remSqEuler(5,13)
#5 #puts squareRootFp(7,2) #5 puts squareRootFp(7,2)
#6 #puts primalityTest(10) #6 puts primalityTest(13)