Fibonacci numbers are the numbers in a sequence in which the

Fibonacci numbers are the numbers in a sequence in which the first two elements are 0 and 1, and the value of each subsequent element is the sum of the previous two elements: 0, 1, 1, 2, 3, 5, 8, 13, ... Write a MATLAB program in a script file using a for-loop that determines and displays the first 20 Fibonacci numbers.

Solution

script.m :

a=0

b=1

c=0

disp(a)

disp(b)

for i=2:20

c=a+b

fprintf(\"%d\\t\",c)

a=b

b=c

end

 Fibonacci numbers are the numbers in a sequence in which the first two elements are 0 and 1, and the value of each subsequent element is the sum of the previou

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site