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:
Solution:
Program to generate first n terms of the Fibonacci Series.
Code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
1 comment:
Nice Post.
Python Online Training
Post a Comment