-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfibonacci.py
More file actions
43 lines (20 loc) · 764 Bytes
/
fibonacci.py
File metadata and controls
43 lines (20 loc) · 764 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
# Fibbonacci Sequence
N = int(input("enter the limit: "))
def fibonacci_seq(N):
fibblist = [1]
for i in range(N):
present_term = fibblist[i]
previous_term = fibblist[i-1]
next_term = previous_term + present_term
new_term = next_term
fibblist.append(new_term)
return fibblist
resulted_fibb = fibonacci_seq(N)
# Do you want to list all the sequence or a specific nth value in the Sequence
# enter the number to display the nth term value of the Sequence
print("To display whole list enter the '0' else enter the nth term number.")
nth_value = int(input("Enter the number for nth value : "))
if nth_value != 0:
print(f'the requested term in the fibonacci Seq is ▶︎ {resulted_fibb[nth_value]}')
else:
print(resulted_fibb)