Skip to content

Instantly share code, notes, and snippets.

@liuhuajin
Created July 7, 2014 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuhuajin/8d6f9757ec222cdf73ec to your computer and use it in GitHub Desktop.
Save liuhuajin/8d6f9757ec222cdf73ec to your computer and use it in GitHub Desktop.
lua leaning
--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")
print(fact(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment