Sha256: e7c9062b52a5146acafdad4676c94174b58cdaa3e3946184e199f991972c6d60

Contents?: true

Size: 228 Bytes

Versions: 1

Compression:

Stored size: 228 Bytes

Contents


class ClosestFibonacci
	
end

class Integer < Numeric
  def closest_fibonacci
    my_i = self.to_i

		return nil if my_i == 0
		return 0 if my_i == 1

		a, b = 0, 1
		while (b < my_i) do
			a, b = b, a+b
		end 

		a
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
closest_fib_gem-0.1.0 lib/closest_fib_gem.rb