%%% ====================================================================== %%% Print a table of representable Fibonacci sequence values. Metafont %%% numbers are fixed-point values stored in a 32-bit word, limited to %%% 12 integer and 16 fractional bits. Output facilities are very %%% primitive, and there is no coercion of numbers to strings, so %%% number can be shown only one per line. %%% %%% Usage: %%% mf Fibonacci3.mf %%% %%% [20-Apr-2002] %%% ====================================================================== golden_ratio = (1 + sqrt(5))/2; def Fibonacci = limit := 2047; % 2^11 - 1 lo := hi := n := 1; show n,lo; forever: exitif hi>limit; message "--------------------"; n := n + 1; ratio := hi/lo; show n, hi, ratio, (ratio - golden_ratio); hi := lo + hi; lo := hi - lo; endfor; enddef; Fibonacci; bye;