-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathP17.py
More file actions
33 lines (30 loc) · 987 Bytes
/
P17.py
File metadata and controls
33 lines (30 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
n = int(input("How many terms do you want to print? : "))
n1 = 0
n2 = 1
if(n<=0):
print("Invalid Input!!!")
elif(n==1):
print("Fibonacci Series : ",n1)
elif(n==2):
print("Fibonacci Series : ",n1,",",n2)
else:
print("Fibonacci Series : ")
for i in range(n):
if(i<n-1):
print(n1,end=' , ')
else:
print(n1)
n3 = n1+n2
n1 = n2
n2 = n3
''' Output
How many terms do you want to print? : 1
Fibonacci Series : 0
OR
How many terms do you want to print? : 2
Fibonacci Series : 0 , 1
OR
How many terms do you want to print? : 10
Fibonacci Series :
0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34
'''