Print the Fibonacci series up to n terms

In this program, we will print the Fibonacci series up to n terms.

Steps to solve the program
  1. Take a number as input up to which you want to print the Fibonacci series.
  2. Create two variables num1, and num2 and assign their values equal to 0 and 1.
  3. Create a count variable and assign its values equal to 0.
  4. While the count variable is less than the input term print num1.
  5. Add num1 and num2 and store the result in a new variable n2.
  6. Change num1 to num2 and num2 to n2 and add 1 to the count variable.
  7. Print the output.
				
					num = int(input("Enter the number= "))
count = 0
num1,num2 = 0,1
print("Sequence is: ",end=" ")

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

Output :

				
					Enter the number= 15
Sequence is:  0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 
				
			

print all Perfect numbers between 1 to n

print the multiplication table of any number

Leave a Comment