Skip to content

Instantly share code, notes, and snippets.

@lilliealbert
Created April 10, 2013 17:12
Show Gist options
  • Save lilliealbert/5356538 to your computer and use it in GitHub Desktop.
Save lilliealbert/5356538 to your computer and use it in GitHub Desktop.
def factorial(n)
if n == 0
return 1
end
total = n
(n-1).times do
total = total * (n - 1)
n -= 1
end
total
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment