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

The Fibonacci sequence is the following: 1,1,2,3,5, 8,13,21,... The sequence sta

ID: 3695151 • Letter: T

Question

The Fibonacci sequence is the following: 1,1,2,3,5, 8,13,21,... The sequence starts with 1 and 1, then all subsequent values are determined by summing the previous two numbers in the sequence. Have your program display the first N Fibonacci numbers in a column, where N is a number you select. Choose a value of N that is greater than 2 (do not use the input function, simply hard-code the value of N by typing N = some number greater than 2). For example, if you choose N=6 the program should display: 1 1 Use mat lab. Do riot use built-in function. Calculate all Fibonacci numbers except the first two (1,1) using a for loop and display them on the screen. Although you will assign a value to N in your program, make your algorithm general for any value of N > 2.

Explanation / Answer

n = 6;

one = 1;
two = 1;

% looping for n times
for i = 1:n

% printing value in one
disp(one)
  
% then updating the values of one and two
temp = one;
> two = temp + two;
end

% Output

1
1
2
3
5
8

n = 6;

one = 1;
two = 1;

% looping for n times
for i = 1:n

% printing value in one
disp(one)
  
% then updating the values of one and two
temp = one;
> two = temp + two;
end

% Output

1
1
2
3
5
8

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote