Mersenne primes: Difference between revisions
Content added Content deleted
(Added Lua version) |
m (→{{header|Lua}}) |
||
Line 607: | Line 607: | ||
=={{header|Lua}}== |
=={{header|Lua}}== |
||
This checks for primality using a trial division function. The limitation is 'until p == p + 1', meaning that the program will halt when Lua's number type (a 64-bit floating point value) no longer has enough precision to distiguish between one integer and the next. |
This checks for primality using a trial division function. The limitation is 'until p == p + 1', meaning that the program will halt when Lua's number type (a 64-bit floating point value) no longer has enough precision to distiguish between one integer and the next. |
||
<lang lua>-- Returns boolean |
<lang lua>-- Returns a boolean to show whether x is prime |
||
function isPrime (x) |
function isPrime (x) |
||
if x < 2 then return false end |
if x < 2 then return false end |