### -*-hoc-*- ### ==================================================================== ### 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). ### [17-Aug-2005] ### ==================================================================== golden_ratio := (1.0 + sqrt(5.0))/2.0 lo = hi = n = 1 printf("%3d\t%25...3d\n", n, lo) limit = MAXINT while (hi < limit) \ { n++ ratio = hi/lo if (P <= 53) \ printf("%3d\t%25...3d\t%19.15f\%19.15f\n", n, hi, ratio, (ratio - golden_ratio)) \ else if (P <= 64) \ printf("%3d\t%25...3d\t%22.18f\%22.18f\n", n, hi, ratio, (ratio - golden_ratio)) \ else \ printf("%3d\t%25...3d\t%39.35f\%39.35f\n", n, hi, ratio, (ratio - golden_ratio)) hi = lo + hi lo = hi - lo }