Created
July 3, 2013 18:51
-
-
Save BooneTeam/5921637 to your computer and use it in GitHub Desktop.
Recursive Factorial Solution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial_recursion(n, factorial = 1) | |
return factorial if n == 1 | |
factorial *= (n) | |
factorial(n-1, factorial) | |
end | |
puts factorial_recursion(5) | |
#Run it at CodePad.org |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment