Jump to content

Module:Sandbox/sameboat2

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sameboat (talk | contribs) at 05:59, 19 March 2013. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
my_object = {};

function factorial(n)
    if n == 0 then
        return 1 --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 frame.args[1] == 3 then
            return 20 --testing, doesn't have to make any sense
        else
            return arg1
        end
    local output = '';
    for index = 1,arg1 do
        output = output .. index .. ") n! = " .. factorial(index) .. "<br \>\n"
    end
    return output;
end

return my_object