% fibonacci_keep2.m
%  Evaluate the Fibonacci sequence using a two-step stepping stone.
%
n = input ( 'Enter the element index: ' );

for i = 0 : n

  if ( i == 0 )
    f = 1;
  elseif ( i == 1 )
    fold = f;
    f = 1;
  else
    foldest = fold;
    fold = f;
    f = fold + foldest;
  end

  fprintf ( 'F(%d) = %d\n', i, f );

end

