Sha256: 6c88a51f19179c97eee758b2554af5b58b38a2ed08c361650650e5bc5ca29cca

Contents?: true

Size: 288 Bytes

Versions: 3

Compression:

Stored size: 288 Bytes

Contents

# additional functions for Class::Integer

class Integer
  # factorial method for an Integer
  # @return [Integer] factorial for given Integer
  # @example factorial for 5
  #   !5
  #   => 120
  def !
    if self == 0
      return 1
    else
      (1..self).inject(:*)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
viral_seq-1.0.2 lib/viral_seq/Integer.rb
viral_seq-1.0.1 lib/viral_seq/Integer.rb
viral_seq-1.0.0 lib/viral_seq/Integer.rb