Ad

perfectly hidden cache is the one that is absent.

Code
Diff
  • def fibonacci(n, a=0, b=1):
        if n == 0: return 0
        if n == 1: return b
        else:
            return fibonacci(n-1, b, a+b)
    • def fibonacci(b, cache={}):
    • if b <= 1:
    • return b
    • if b in cache:
    • return cache[b]
    • cache[b] = fibonacci(b-1, cache) + fibonacci(b-2, cache)
    • return cache[b]
    • def fibonacci(n, a=0, b=1):
    • if n == 0: return 0
    • if n == 1: return b
    • else:
    • return fibonacci(n-1, b, a+b)