Recursive Ruby - Factorials

14 December 2013
def factorial(n)
  if n == 0
    1
  else
    n * factorial(n - 1)
  end
end
factorial(5)
//=> 120