RosettaCodeData/Task/Primality-by-Wilsons-theorem/PureBasic/primality-by-wilsons-theore...

23 lines
345 B
Plaintext

Procedure wilson_prime(n.i)
fct.i = 1
For i.i = 2 To n-1
fct = (fct * i) % n
Next i
If fct = n-1
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
OpenConsole()
PrintN("Primes below 100")
For i = 2 To 100
If wilson_prime(i)
Print(Str(i) + #TAB$)
EndIf
Next i
PrintN("")
Input()
CloseConsole()