Created
October 8, 2013 23:10
-
-
Save Davidslv/6893396 to your computer and use it in GitHub Desktop.
factorial
This file contains 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
# This are examples of how to implement a factorial in Ruby | |
def ft(n) | |
return 1 if n <= 1 | |
n.downto(1).inject(:*) | |
end | |
def factorial(n) | |
return 1 if n <= 1 | |
n * factorial(n - 1) | |
end |
Author
Davidslv
commented
Oct 8, 2013
Read the one made with erlang here: https://gist.github.com/Davidslv/8832054
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment