Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/viral_seq/math.rb

Overview

additional functions for Class::Integer

Instance Method Summary collapse

Instance Method Details

#!Integer

factorial method for an Integer

Examples:

factorial for 5

!5
=> 120


160
161
162
163
164
165
166
# File 'lib/viral_seq/math.rb', line 160

def !
  if self == 0
    return 1
  else
    (1..self).inject(:*)
  end
end