Question

Prepare a flowchart and MATLAB program that will calculate

Q2: Fibonacci series is f1=1 f2=1 fn=fn-1+fn-2 (n>2) What is f20?

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

In Fibonacci series first term is 0 and 2nd term is 1.But as you have specified here that both f1 and f2 must be initialized to 1 I have written program accordingly.

Here the program below will print all numbers of Fibonacci series uptill the desired term.(Generalized program)

f1= 1;
f2 = 1;
n = input('Enter number of term desired');
for i = 1:n-2 %term for n
fprintf('\t')
fprintf('%d',f1);
f3 = f1 + f2;
f1 = f2;
f2 = f3;
end

In case you need only 20th term,then

f1 = 1;
f2 = 1;
n = input('Enter number of term desired');

for i = 1:18 %term for n
f3 = f1 + f2;
f1 = f2;
f2 = f3;
end

fprintf("%d",f1);

*Please ensure to do indentation of code written inside For loop properly ,because sometime when we submit answer from here it is automatically left aligned and indentation may be disturbed.we are looping till (n-2) because 1st and 2nd term(f1 and f2) have already been specified or initialized by us.

Flowchart :

(START 11=1, fi= 1 [f2=1 Accept value l op n V16 No icn-2 (STOP Yes I | f3=fitfa / fi=fz 1 f2 = F3 Notes SEPTEN M 1 81 T 291

Please Up-Vote if you find this solution helpful !! In case if you have any doubt or query feel free to comment below.

Add a comment
Know the answer?
Add Answer to:
Prepare a flowchart and MATLAB program that will calculate Q2: Fibonacci series is f1=1 f2=1 fn=fn-1+fn-2...
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