24 lines
410 B
Text
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
|