http://www.noulakaz.net/weblog/2007/03/ ... e-numbers/
http://montreal.pm.org/tech/neil_kandalgaonkar.shtml
it will work for small numbers but not for a number like 1234567891 or 123456781 it will say it is prime even it is composite, this is because the capacity of string variable or the engine itself.
feel free to change it or to explain how it works
Code: Select all
number=13
sNum.s = LSet("1", number,"1") ; make string from 13 "1"'s
CreateRegularExpression(0, "^1?$|^(11+?)\1+$")
a = MatchRegularExpression(0, sNum)
If a =0
Debug ("number = " + number + " is prime")
Else
Debug ("number = " + number + " is not prime")
EndIf