Get the Fibonacci series between 0 to 20.

In this program, we will get the Fibonacci series between 0 to 20.

Steps to solve the program
  1. Create two variables and assign their values equal to 0 and 1 respectively.
  2. Create another variable count and assign its value equal to 0.
  3. While the count variable is less than 20 print the num1.
  4. Add num1 and num2 and assign their addition to the n2 variable.
  5. Change the value of num1 with num2 and num2 with n2.
  6. Add 1 to the count variable.
  7. Print the Fibonacci series.
				
					num1 = 0
num2 = 1
count = 0

while count < 20:
    print(num1,end=" ")
    n2 = num1 + num2
    num1 = num2
    num2 = n2
    count += 1  
				
			

Output :

				
					0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 
				
			

prints all the numbers from 0 to 6 except 3 and 6

Fizz-Buzz program

Leave a Comment