Skip to content

Instantly share code, notes, and snippets.

@jesuino
Created September 17, 2024 17:11
Show Gist options
  • Save jesuino/c7d9c632c692ffe13f8945706f6df710 to your computer and use it in GitHub Desktop.
Save jesuino/c7d9c632c692ffe13f8945706f6df710 to your computer and use it in GitHub Desktop.
-- 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment