Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jackfrued
GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/公开课/年薪50W+的Python程序员如何写代码/code/Python/opencourse/part01/example07.py
3078 views
1
from functools import lru_cache
2
3
4
@lru_cache()
5
def fib(num):
6
if num in (1, 2):
7
return 1
8
return fib(num - 1) + fib(num - 2)
9
10
11
for n in range(1, 121):
12
print(f'{n}: {fib(n)}')
13
14