-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy13.py
More file actions
41 lines (37 loc) · 676 Bytes
/
py13.py
File metadata and controls
41 lines (37 loc) · 676 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
34
35
36
37
38
39
40
41
'''n=int(input("enter num"))
n1=0
n2=1
if n==0:
print("enter +ve integer")
else:
while >0:
n3=n1+n2
n2=n1
n2=n3
n-=1
print(n3)'''
nterms = int(input("How many terms? "))
num1, num2 = 0, 1
count = 0
series = []
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
series.append(num1)
else:
while count < nterms:
series.append(num1)
nth = num1 + num2
num1 = num2
num2 = nth
count += 1
print("Fibonacci sequence:")
for i in series:
print(i)
'''else:
for i in range(0,n+1):
n1=i+n2
n2=i
i=n1
n-=1
print(n1)'''