Sunday, February 10, 2019

Fibonacci Series (in Python)

Q. Write a Python program to generate the first n terms of the Fibonacci Series.

Solution:

Program to generate first n terms of the Fibonacci Series.

Code:

n = int(input('Enter number of terms:'))
term1 = 0
term2 = 1
for i in range(0,n):
print(term1,end=', ')
nextT = term1 + term2
term1 = term2
term2 = nextT
view raw Fibonacci.py hosted with ❤ by GitHub