function make(n, d)
    local a = {}
    for i=1,n do
        table.insert(a, d)
    end
    return a
end

function reverse(t)
    local n = #t
    local i = 1
    while i < n do
        t[i],t[n] = t[n],t[i]
        i = i + 1
        n = n - 1
    end
end

function tail(list)
    return { select(2, unpack(list)) }
end

function divisors(n)
    local divs = {}
    table.insert(divs, 1)

    local divs2 = {}

    local i = 2
    while i * i <= n do
        if n % i == 0 then
            local j = n / i
            table.insert(divs, i)
            if i ~= j then
                table.insert(divs2, j)
            end
        end
        i = i + 1
    end

    reverse(divs)
    for i,v in pairs(divs) do
        table.insert(divs2, v)
    end
    return divs2
end

function abundant(n, divs)
    local sum = 0
    for i,v in pairs(divs) do
        sum = sum + v
    end
    return sum > n
end

function semiPerfect(n, divs)
    if #divs > 0 then
        local h = divs[1]
        local t = tail(divs)
        if n < h then
            return semiPerfect(n, t)
        else
            return n == h
                or semiPerfect(n - h, t)
                or semiPerfect(n, t)
        end
    else
        return false
    end
end

function sieve(limit)