from functools import lru_cache def fib(x): if x < 2: return 1 return fib(x-1) + fib(x-2) @lru_cache(maxsize=10000) def cfib(x): if x < 2: return 1 return fib(x-1) + fib(x-2)