aboutsummaryrefslogtreecommitdiff
path: root/challenge-141/abigail/lua/ch-1.lua
blob: f9b626f6a92fef6194671ff691375c1192954a50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/opt/local/bin/lua

--
-- See ../README.md
--

--
-- Run as: lua ch-1.lua
--

local count         = 10
local nr_of_divisor =  8

local n = 0
while count > 0 do
    n = n + 1
    local s = math . floor (math . sqrt (n))
    if n == s * s then
        goto end_while
    end
    local c = 0
    for d = 1, s do
        if n % d == 0 then
            c = c + 2
            if c > nr_of_divisor then
                goto end_while
            end
        end
    end
    if c == nr_of_divisor then
        print (n)
        count = count - 1
    end

    ::end_while::
end