RosettaCodeData/Task/Primality-by-Wilsons-theorem/Liberty-BASIC/primality-by-wilsons-theorem.basic
2026-04-30 12:34:36 -04:00

24 lines
410 B
Text

' Primality by Wilson's theorem
for n = 2 to 50
if esPrimoWilson(n) then
print n
end if
next n
end
function esPrimoWilson(p)
if p <= 1 then
esPrimoWilson = 0
exit function
end if
fact = 1
for i = 1 to p-1
fact = fact * i
next i
if ((fact + 1) mod p) = 0 then
esPrimoWilson = 1
else
esPrimoWilson = 0
end if
end function