Created
November 15, 2015 21:48
-
-
Save andrewjkerr/cfe3ca34b98c4810906c to your computer and use it in GitHub Desktop.
Ruby is great, isn't it?
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
# Accepts an integer n | |
# Returns the factorial of n | |
def fact(n) | |
return nil if n < 1 | |
(1..(n.to_i)).reduce(:*) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment