Module: Gemmy::Patches::IntegerPatch::InstanceMethods::Factorial

Defined in:
lib/gemmy/patches/integer_patch.rb

Instance Method Summary collapse

Instance Method Details

#factorialObject

facets



11
12
13
14
15
16
# File 'lib/gemmy/patches/integer_patch.rb', line 11

def factorial
  return 1 if zero?
  f = 1
  2.upto(self) { |n| f *= n }
  f
end