Method: Euler#find_missing_pyth_value
- Defined in:
- lib/euler.rb
#find_missing_pyth_value(a, b, c) ⇒ Object
Given two values of a pythagorean triplet, and nil for the missing value, it returns the missing value.
Euler.find_missing_pyth_value(nil, 4, 5) # => 3
171 172 173 174 175 |
# File 'lib/euler.rb', line 171 def find_missing_pyth_value(a, b, c) return Math.sqrt(c**2 - b**2) if a.nil? return Math.sqrt(c**2 - a**2) if b.nil? return Math.sqrt(a**2 + b**2) if c.nil? end |