RosettaCodeData/Task/Primality-by-Wilsons-theorem/Run-BASIC/primality-by-wilsons-theorem.basic

14 lines
271 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
print "Primes below 100"
for i = 2 to 100
if wilsonprime(i) = 1 then print i; " ";
next i
end
function wilsonprime(n)
fct = 1
for i = 2 to n-1
fct = (fct * i) mod n
next i
if fct = n-1 then wilsonprime = 1 else wilsonprime = 0
end function