Class: Fixnum
- Inherits:
-
Object
- Object
- Fixnum
- Defined in:
- lib/mc-fib.rb
Instance Method Summary collapse
Instance Method Details
#closest_fibonacci ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/mc-fib.rb', line 3 def closest_fibonacci #find fib until fib = [0, 1] i = 1 while fib[i] < self do fib[i+1] = fib[i] + fib[i-1] i += 1 end fib[-2] end |