Skip to content

Instantly share code, notes, and snippets.

View michaelrkn's full-sized avatar

Michael Kaiser-Nyman michaelrkn

View GitHub Profile
@michaelrkn
michaelrkn / factorial.rb
Last active December 11, 2015 16:48 — forked from pjlowry/factorial.rb
def factorial(n)
if n < 0
raise "You can't take the factorial of a negative number."
elsif n == 0
1
else
(1..n).inject(:*)
end
end