Skip to content

Instantly share code, notes, and snippets.

@danielnegri
Forked from bitops/factorial.rb
Created June 2, 2012 17:46
Show Gist options
  • Select an option

  • Save danielnegri/2859331 to your computer and use it in GitHub Desktop.

Select an option

Save danielnegri/2859331 to your computer and use it in GitHub Desktop.
Factorial in Ruby 1.9.2
def factorial(n)
(1..n).reduce(:*)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment