Question

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

n = 20; %20 terms
fib = zeros(1, n);
fib(2) = 1;
for i = 3:n
fib(i) = fib(i-1) + fib(i-2);
end
fib

output

=====

fib =

 Columns 1 through 11:

      0      1      1      2      3      5      8     13     21     34     55

 Columns 12 through 20:

     89    144    233    377    610    987   1597   2584   4181
Add a comment
Know the answer?
Add Answer to:
3[20%] | Fibonacci numbers are the numbers in a sequence in which the first two ele-...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT