Skip to content

Instantly share code, notes, and snippets.

@FsDevNinja
Created November 1, 2016 17:20
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 FsDevNinja/c818e5fb9a615f0356be4aa9ac6d5885 to your computer and use it in GitHub Desktop.
Save FsDevNinja/c818e5fb9a615f0356be4aa9ac6d5885 to your computer and use it in GitHub Desktop.
getting the factorials of given number
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