class Integer
Public Instance Methods
closest_fibonacci()
click to toggle source
# File lib/ext/core/integer.rb, line 3 def closest_fibonacci raise InvalidArgumentError.new("Cannot be less than zero") if self < 0 return self if [0,1].include?(self) x, y = 1, 1 while((x+y) < self) do x, y = (x+y), x end x end