Jump to content

Module:Sandbox/sameboat

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sameboat (talk | contribs) at 01:07, 19 March 2013. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
    -- defines a factorial function
    function fact (n)
      if n == 0 then
        return 1
      else
        return n * fact(n-1)
      end
    end
    
    print("enter a number:")
    a = io.read("*number")        -- read a number
    print(fact(a))