%Clear screen and memory
clear; clc; format compact
% Initialize the first two values
f(1) = 1;
f(2) = 1;
% Create the first 30 Fibonacci numbers
for i = 3 : 30
% Perform the sum of terms accordingly
f(i) = f(i-1) + f(i-2);
% Calculate and display the ratio of 2 consecutive elements % of the series
golden_ratio = f(i)/f(i-1);
str = [num2str(f(i)) ' ' num2str(f(i-1)) ' ' ...
num2str(golden_ratio, 10)];
disp(str)
end
No hay comentarios:
Publicar un comentario