+ 1
Hi can some body explain me about a program to give Fibonacci series in the output?
I have a problem with the statement part of that program : wrote a program to give Fibonacci series in the outnput: sum=a+b; cout << sum; a=b; b=sum ; Please explain that what is going on the last two lines?
2 Respostas
+ 2
Fibonacci series is: a number is sum of previous two consecutive numbers..
ex:
a = 0, b = 1
Next number is a+b = 0+1
0,1,1 (=> a=1, b=1)
Next number should be 1+1=2
0,1,1,2
Next number should be 1+2=3 (a=1, b=2)
0,1,1,2,3....
Each time you need to change b to a so a=b, and sum to b, so b=sum.
Hope it helps..
+ 1
Jayakrishna🇮🇳 Thanks a lot🙏🏻❤