;;; This scheme version is for bigloo scheme, which follows more
;;; closely the language definition than GNU guile does.  bigloo has
;;; the complex (do...) instead of (while ...), but lacks Scheme's
;;; (printf ...).  Also, its integers are limited to 29 bits (3 less
;;; than C's int datatype), instead of expanding automatically, and
;;; transparently, into multiple-precision integers, as most other
;;; Scheme and Lisp implementations do.

(define GOLDEN-RATIO (/ (+ 1.0 (sqrt 5.0)) 2.0))

(define (Fibonacci)
  "Print a table of representable Fibonacci sequence values."
  (let ((hi 1)
	(lo 1)
	(n 1)
	(ratio 0))
    (write n) 
    (display " ") 
    (write lo)
    (newline)
    (do ()
	((>= hi (expt 2 28)))		;loop exit condition
	(set! n (+ 1 n))
	(set! ratio (/ (exact->inexact hi) (exact->inexact lo)))
	(write n)
	(display " ") 
	(write hi)
	(display " ") 
	(write ratio)	
	(display " ") 
	(write (- ratio GOLDEN-RATIO))
	(newline)
	(set! hi (+ lo hi))
	(set! lo (- hi lo)))))

(Fibonacci)
