clear all;
tol=1e-15;

% initializing the sequences
n=2;
% f(0)=1 cannot be entered in Matlab
f(1)=1;
f(2)=2;
r(1)=1;
r(2)=f(2)/f(1);

while abs(r(n) - r(n-1)) > tol
    % advance n and append new values to f and r arrays
    n=n+1;
    f(n)=f(n-1)+f(n-2);
    r(n)=f(n)/f(n-1);
end

index=1:n; % set up array of n-values
F=[index; f; r];
fprintf('  %3d   %9d     %20.15f \n',F);
% note that fprintf reads format specifiers row-wise