19 - Write a program in Python to display the first 'n' terms of a Fibonacci series.
a=0
b=1
n=int(input("Enter the number of terms to be printed for fibonacci Series: "))
print(a, b,end=' ')
for i in range(1,n-1):
c=a+b
print(c,end=' ')
a=b
b=c
Output:
Enter the number of terms to be printed for fibonacci Series: 10
0 1 1 2 3 5 8 13 21 34
No comments:
Post a Comment