-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFibonacci-Number-Exercise
56 lines (42 loc) · 2.19 KB
/
Fibonacci-Number-Exercise
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#Give a Fibonacci number and return all the numbers leading up to that number
#Use a generator
#Personal Bonus have it print out Fn(n= sequence number) = Fibonacci number
def fib(fn):
a = 0
b = 1
if fn <= 1:
return f"Fn{fn} = {fn}"
else:
for i in range(2, fn+1):
c = a + b
a = b
b = c
return f"Fn{fn} = {b}"
num = int(input("Which Fibonacci number would you like to see? "))
print(fib(num))
/\ /\
| \ / |
| \ / \ / |
| \ /\ / \ / \ / |
| \ ^ / \/ \/ \ ^ / |
| |
/ \
/ \ / \
/ | \ / | \
/ | \ / | \
/ | @\ /@ | \
/ | \ / | \
/ \___/ \___/ \
/ \
/ |\______________________/| \
/ \ | | | | | | | /\ \
/ / \ | | | | | | | / \ \
/ / \ | | | | | | | / \ \
/ / \ \ | | | | | / / \ \
/ \ \ \_|___|___|___|___|__/ / / \
\/\/\/ /\ /\ \/\/\/
/ \ / \
| |
| \____________________/ |
\ | | /
<_________/ \_________>