Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,55 @@
input "Input a number:";n
input "Input test:";k
test = millerRabin(n,k)
if test = 0 then
print "Probably Prime"
else
print "Composite"
end if
wait
' ----------------------------------------
' Returns
' Composite = 1
' Probably Prime = 0
' ----------------------------------------
FUNCTION millerRabin(n, k)
if n = 2 then
millerRabin = 0 'probablyPrime
goto [funEnd]
end if
if n mod 2 = 0 or n < 2 then
millerRabin = 1 'composite
goto [funEnd]
end if
d = n - 1
while d mod 2 = 0
d = d / 2
s = s + 1
wend
while k > 0
k = k - 1
base = 2 + int(rnd(1)*(n-3))
x = (base^d) mod n
if x <> 1 and x <> n-1 then
for r=1 To s-1
x =(x * x) mod n
if x=1 then
millerRabin = 1 ' composite
goto [funEnd]
end if
if x = n-1 then exit for
next r
if x<>n-1 then
millerRabin = 1 ' composite
goto [funEnd]
end if
end if
wend
[funEnd]
END FUNCTION