      program Fibonacci3
*     (Fibonacci)
*     Print ascending members of the Fibonacci sequence that are
*     representable as 64-bit signed integers, prefixed by their term
*     numbers, and followed by the ratio of successive terms, to
*     demonstrate the 1.618...^n growth (the ratio approaches the golden
*     ratio, (1 + sqrt(5))/2 = 1.6180339887498949, and reaches it (to
*     machine precision) at 41 terms: the fourth item on each line is
*     the difference from the golden ratio).
*     (19-Apr-2002)
      character*1 TAB
      parameter (TAB = char(9))
*
      double precision GOLDEN_RATIO
      double precision ratio
      integer*8 lo, hi, n
*
      GOLDEN_RATIO = (1.0d0 + sqrt(5.0d0))/2.0d0
*
      lo = 1
      hi = 1
      n = 1
      write (6,'(i2,a,i19)') n, TAB, lo
      do while (hi .GT. 0)
          n = n + 1
          ratio = dble(hi)/dble(lo)
          write (6,'(i2,a,i19,a,f19.15,a,f19.15)') n, TAB, hi, TAB,
     X        ratio, TAB, (ratio - GOLDEN_RATIO)
	hi = lo + hi
	lo = hi - lo
      end do
*
      end
