CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/公开课/文档/年薪50W+的Python程序员如何写代码/code/Python/opencourse/part01/example07.py
Views: 729
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