%% clear workspace and close figures
close all; clear all; clc

%% initialize variable f to store Fibonacci numbers
f = zeros(20,1);
f(1) = 0; f(2) = 1;

%% Fibonacci sequence
for j = 3:length(f),
    f(j) = f(j-2) + f(j-1);
    if f(j) <= 10,
        str = sprintf('%2drd Fibonacci number smaller than or equal to 10',j);
    else
        str = sprintf('%2drd Fibonacci number greater than 10',j);
    end
    if j == 19, str = [ str ' --- puh, almost done...' ]; end
    disp(str)
end

%% plot sequence in semilogy and compare with golden section ratio
semilogy(f); hold on
q = (1+sqrt(5))/2;
semilogy(q.^(1:length(f)),'r--')
xlabel('n')
legend('Fibonacci sequence f_n','1.6180^n','Location','NorthWest')

