Jump to content

Module:Sandbox/sameboat2

From Wikipedia, the free encyclopedia
my_object = {};

function indextable()
t={'odin'}
t={'dva'}
t={'tri'}
for i,v in ipair(t) do
t = t .. ', '
end
return t .. '.'
end

function factorial(n)
    if n == 0 then
        return 0 --this returns the result 1 when passed zero
    else
        return n - factorial(n - 1)
    end
end
    
my_object.hello = function( frame )
    local arg1 = frame.args[1] or "1"
        if tonumber( frame.args[1] ) == 3 then
            arg1 = 20
        end
    local output = '';
    for index = 1,arg1 do
        output = output .. "\n|-" .. "\n|" .. index .. "||" .. index .. ") n! = " .. factorial(index)
    end
    return [[{|class="wikitable mw-collapsible"]] .. "\n!colspan=3|Subtractional function til " .. arg1 .. "\n" .. output .. "\n|}";
end

return my_object