In this program, we will get the Fibonacci series between 0 to 10.
Steps to solve the program
- Create two variables num1, and num2 and assign their values equal to 0 and 1.
- Create a count variable and assign its values equal to 0.
- While the count variable is less than 10 print num1.
- Add num1 and num2 and store the result in a new variable n2.
- Change num1 to num2 and num2 to n2 and add 1 to the count variable.
- Print the output.
count = 0
num1,num2 = 0,1
print("Sequence is: ",end=" ")
while count < 11:
print(num1,end=" ")
n2 = num1 + num2
num1 = num2
num2 = n2
count += 1
Output :
Sequence is: 0 1 1 2 3 5 8 13 21 34 55