Sha256: c7d0ad21f061afeaf4183e8b2e8a18e0dcc5041bc449cdd7dd0cf73426351756

Contents?: true

Size: 250 Bytes

Versions: 5

Compression:

Stored size: 250 Bytes

Contents

require 'darkext/array'

class Integer
  # Computes the factorial of the Integer
  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
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
darkhelmet-darkext-0.11.0 lib/darkext/integer.rb
darkhelmet-darkext-0.11.1 lib/darkext/integer.rb
darkhelmet-darkext-0.11.2 lib/darkext/integer.rb
darkhelmet-darkext-0.12.0 lib/darkext/integer.rb
darkext-0.12.0 lib/darkext/integer.rb