Code: Select all
Dim s.s(1)
s(0) = " = 0 so it's a prime"
fact + 1
Debug Chr($8000)
For n = 2 To 21
Debug Rset(Str(fact + 1), 24, " ") + "+1 % " + Str(n) + s(Bool((fact + 1) % n) )
fact * n
Next
Code: Select all
Dim s.s(1)
s(0) = " = 0 so it's a prime"
fact + 1
Debug Chr($8000)
For n = 2 To 21
Debug Rset(Str(fact + 1), 24, " ") + "+1 % " + Str(n) + s(Bool((fact + 1) % n) )
fact * n
Next
Code: Select all
Procedure isPrime(p)
Protected a = p - 1
Protected b
For i = p - 2 To 2 Step -1
a * i
a % p
Next
a + 1
ProcedureReturn Bool(a = p)
EndProcedure