Python program to print the fibonacci series

1390
Python program to print the fibonacci series
n=int(input("How many terms you want to go? "))
n1, n2 = 0, 1
count = 0
if n <= 0:   # check if the number of terms is valid
   print("Please enter a positive number")
elif n == 1:
   print("Fibonacci sequence upto",n,":")
   print(n1)
else:
   print("Fibonacci series:")
   while count < n:
       print(n1)
       nth = n1 + n2
       # update values
       n1 = n2
       n2 = nth
       count += 1

     Output 1:
            How many terms you want to go? 9
            Fibonacci series:
            0
            1
            1
            2
            3
            5
            8
            13
            21
     Output 2:
            How many terms you want to go? -2
            Please enter a positive number

इन्हें भी देखें।

Python Programs के लिये यहाँ click करें।

 

 

 

Python program to print the fibonacci series Python program to print the Fibonacci sequence program to print the Fibonacci series in python program to print the Fibonacci sequence in python write a Python program to print the Fibonacci series write a Python program to print the Fibonacci sequence write a program to print the Fibonacci series write a program to print the Fibonacci sequence write a program to print the Fibonacci series in python write a program to print the Fibonacci sequence in python fibonacci series fibonacci sequence fibonacci series program fibonacci sequence program fibonacci series program in python fibonacci sequence program in python