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/公开课/文档/第05次公开课-算法入门系列1-周而复始/code/example04.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 num in range(1, 101):
12
print(f'{num}: {fib(num)}')
13
14