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

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

Instance Method Summary collapse

Instance Method Details

#factorialObject

facets



69
70
71
72
73
74
# File 'lib/gemmy/patches/integer_patch.rb', line 69

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