Junk

Junk Commit Details

Date:2019-02-12 20:48:17 (5 months 10 days ago)
Author:Nicola Fontana
Branch:master
Commit:72f789caf33cbd5f4898b26fb796a783a7fece3d
Parents: 20106583d0ef796f3b49c35a5760e1f9b29eaaab
Message:sieve.lua: initial import

Changes:
Alua/sieve.lua (full)

File differences

lua/sieve.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function sieve(n)
if not n then n = 10000000 end
local is_prime = {}
for i = 1, n do
is_prime[i] = 1 ~= i
end
for i = 2, math.floor(math.sqrt(n)) do
if is_prime[i] then
for j = i*i, n, i do
is_prime[j] = false
end
end
end
return is_prime
end
local t = sieve(arg[1])
for n = 1, #t do
if t[n] then print(n) end
end

Archive Download the corresponding diff file

Branches