Skip to content

Commit 3cc55e5

Browse files
authored
Update 3.py
1 parent 2c6a8a6 commit 3cc55e5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

8/3.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
d = [0] * 100
2+
3+
def fibo(x):
4+
print('f(' + str(x) + ')', end=' ')
5+
if x == 1 or x == 2:
6+
return 1
7+
if d[x] != 0:
8+
return d[x]
9+
d[x] = fibo(x - 1) + fibo(x - 2)
10+
return d[x]
11+
12+
print(fibo(6))

0 commit comments

Comments
 (0)