Class: Integer
Instance Method Summary collapse
-
#fact ⇒ Object
Computes the factorial of the Integer.
Instance Method Details
#fact ⇒ Object
Computes the factorial of the Integer
5 6 7 8 9 |
# File 'lib/darkext/integer.rb', line 5 def fact raise ArgumentError.new('Cannot compute factorial of negative number') if 0 > self return 1 if self.zero? return (1..self).to_a.product end |