Skip to content

Instantly share code, notes, and snippets.

@benlangfeld
Created October 30, 2011 14:56
Show Gist options
  • Save benlangfeld/1325993 to your computer and use it in GitHub Desktop.
Save benlangfeld/1325993 to your computer and use it in GitHub Desktop.
def factorial(number)
number.downto(1).inject(:*)
end
class Integer
def factorial
self.downto(1).inject(:*)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment