Created
November 1, 2016 17:20
-
-
Save FsDevNinja/c818e5fb9a615f0356be4aa9ac6d5885 to your computer and use it in GitHub Desktop.
getting the factorials of given number
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
module Factorial | |
def self.of(number) | |
return nil if number == nil | |
arr = [] | |
(1..number).each do |n| | |
arr << n | |
end | |
arr.inject(:*) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment