Display Fibonacci series up to 10 terms
The Fibonacci Sequence is a series of numbers. The next number is found by adding up the two numbers before it. The first two numbers are 0 and 1.
For example, 0, 1, 1, 2, 3, 5, 8, 13, 21. The next number in this series above is 13+21 = 34.
Expected output:
Fibonacci sequence:
0 1 1 2 3 5 8 13 21 34
Hint:
num1 = 0
andnum2 =1
(first two numbers of the sequence)num1
as the current number of the sequenceres = num1+ num2
num1
andnum2
. Setnum1=num2
andnum2=res
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer