Skip to content

Instantly share code, notes, and snippets.

@alexandreaquiles
Created May 7, 2011 13:54
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 alexandreaquiles/960512 to your computer and use it in GitHub Desktop.
Save alexandreaquiles/960512 to your computer and use it in GitHub Desktop.
Factorial
def fatorial(number)
if (number == 0)
return 1
else
return number * fatorial(number - 1)
end
end
def factorial(n)
(1..n).reduce(:*)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment