Home | History | Annotate | Download | only in scripts
      1 -- defines a factorial function
      2 function fact (n)
      3   if n == 0 then
      4     return 1
      5   else
      6     return n * fact(n-1)
      7   end
      8 end
      9 
     10 print("enter a number:")
     11 a = io.read("*number")        -- read a number
     12 print(fact(a))
     13