% Script Eg3_2
% Fibonacci numbers and the Golden Ratio
  clc
  disp('   n        f_n             r_n  ')
  disp('---------------------------------------')
  
% Initializations
  tol = 10^-15;
  n = 2; 
  f_old = 1;                 % n-1st  Fibonacci number
  f_cur = 1;                 % nth    Fibonacci number
  f_new = 2;                 % n+1st  Fibonacci number
  r_cur = f_cur/f_old;        
  r_new = f_new/f_cur;    
  fprintf('  %2d   %8d    %20.15f \n',n,f_cur,r_cur)
  while(abs(r_new - r_cur)>tol)      
%     Increase n and Update...
      n = n+1;
      f_old = f_cur;
      f_cur = f_new;
      f_new = f_old + f_cur;
      r_cur = r_new; 
      r_new = f_new/f_cur;
      fprintf('  %2d   %8d    %20.15f \n',n,f_cur,r_cur)
  end
      
  
  
      

    