### ======================================================================
### Print a table of representable Fibonacci sequence values.   Ruby
### supports big integers (more than 64 bits), so for comparison with
### other languages, we limit to the loop to 64-bit values
###
### Usage:
###	ruby Fibonacci3.rb
###
### [19-Apr-2002]
### ======================================================================

def Fibonacci()
    lo = hi = n = 1
    golden_ratio = (1.0 + Math.sqrt(5.0))/2.0
    limit = 2**63 - 1
    STDOUT.printf "%2d\t%19.0f\n", n, lo
    while (hi < limit)
	n = n + 1
	ratio = (hi + 0.0) / (lo + 0.0)
	STDOUT.printf "%2d\t%19.0f\t%19.15f\t%19.15f\n",
	    n, hi, ratio, (ratio - golden_ratio)
	hi = lo + hi
	lo = hi - lo
    end
end

Fibonacci()
