Skip to content

Instantly share code, notes, and snippets.

@jackhooper
Last active January 1, 2016 22:09
Show Gist options
  • Save jackhooper/8208386 to your computer and use it in GitHub Desktop.
Save jackhooper/8208386 to your computer and use it in GitHub Desktop.
Calculating the factorial of a given number, written in Ruby.
# Factorial calculator thingimajig
# Jack Hooper 2014
def factorial(n)
(1..n).inject(:*)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment