Module: FactorialFlight

Included in:
Fixnum
Defined in:
lib/factorial_flight.rb,
lib/factorial_flight/version.rb

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#factorial(method = :inject) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/factorial_flight.rb', line 4

def factorial(method = :inject)
  return 'Can not calculate factorial of a negative number' if self < 0

  case method
  when :gamma
    gamma_method
  when :loop
    loop_method
  when :recursive
    recursive_method
  else
    inject_method
  end
end