Module: MathRootHelper

Defined in:
lib/math_root_helper.rb,
lib/math_root_helper/root.rb,
lib/math_root_helper/version.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.cube_root(num) ⇒ Object



6
7
8
# File 'lib/math_root_helper/root.rb', line 6

def self.cube_root(num)
  (num**(1.0/3)).round(14)
end

.nth_root(n, num) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/math_root_helper/root.rb', line 10

def self.nth_root(n, num)
  if n == 0
    "Infinity"
  else
    num**(1.0/n).round(14)
  end
end

.square_root(num) ⇒ Object



2
3
4
# File 'lib/math_root_helper/root.rb', line 2

def self.square_root(num)
  num**(1.0/2).round(14)
end