Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
-- Returns boolean indicate whether x is prime
|
||||
function isPrime (x)
|
||||
if x < 2 then return false end
|
||||
if x < 4 then return true end
|
||||
if x % 2 == 0 then return false end
|
||||
for d = 3, math.sqrt(x), 2 do
|
||||
if x % d == 0 then return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Main procedure
|
||||
local n, i = 0, 42
|
||||
while n < 42 do
|
||||
if isPrime(i) then
|
||||
n = n + 1
|
||||
print("n = " .. n, i)
|
||||
i = 2 * i - 1
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue