% fibonacci_formula.m
%  Exact formula for the N-th Fibonacci number.
%
n = input ( 'Enter the index N: ' );

f = ( ...
      ( ( 1 + sqrt ( 5 ) ) / 2 ) ^ n ...
    - ( ( 1 - sqrt ( 5 ) ) / 2 ) ^ n ...
    ) ...
    / sqrt ( 5 );
%
%  MATLAB regards F as a real number, so we have to ROUND() it
%  so that the %d format will print it nicely.
%
fprintf ( '  F(%d) = %d\n', n, round ( f ) );

