import functools @functools.lru_cache() def fib(iterations): a, b = 0, 1 for _ in range(iterations): a, b = b, a+b return a