Class: Modules::Inherit

Inherits:
Object
  • Object
show all
Defined in:
lib/math_func.rb

Instance Method Summary collapse

Instance Method Details

#factorial(n) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/math_func.rb', line 3

def factorial(n)
  if n == 0 || n == 1
    1
  else
    n = n * factorial(n-1)
  end
end