cache.py 211 B

1234567891011121314
  1. from functools import lru_cache
  2. def fib(x):
  3. if x < 2:
  4. return 1
  5. return fib(x-1) + fib(x-2)
  6. @lru_cache(maxsize=10000)
  7. def cfib(x):
  8. if x < 2:
  9. return 1
  10. return fib(x-1) + fib(x-2)