Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the sequence (y_n)_n greaterthanorequalto 1 defining the Fibonacci numb

ID: 3027552 • Letter: C

Question

Consider the sequence (y_n)_n greaterthanorequalto 1 defining the Fibonacci numbers. Set y_1 = 1 and y_2 = 1 and the relation y_n+1 = y_n + y_n - 1 for n greaterthanorequalto 2. Compute the first 50 Fibonacci numbers 2/1 up to 2/50 and store the 50 numbers in a column vector y (of dimension 50 times 1). Save the column vector y in A13.dat Extract the values from y_10 until y_25 and store the numbers in a column vector. Save this column vector in A14.dat Extract the terms in the sequence with an even index: y_2, y_4, ... Store these numbers in a column vector (where the first row stores y_2, the second row y_4, and so on). Save that vector in A15.dat

Explanation / Answer

function y = fibonacci(50)

% FIBONACCI Fibonacci sequence

% y = FIBONACCI(n) generates the first n Fibonacci numbers

y = zeros(50,1);

y(1) = 1;

y(2) = 1;

for k = 3:50

y(k) =y(k-1) + y(k-2);

end

fileID1 = fopen('A13.dat','w');

fileID2 = fopen('A14.dat','w');

fileID3 = fopen('A15.dat','w');