about summary refs log blame commit diff
path: root/scratch/facebook/interview-cake/nth-fibonacci.py
blob: 4629798cf711d8dabd2d52f15aedd6fc2dc82735 (plain) (tree)
1
2
3
4
5
6





                          
def fib(n):
    cache = (0, 1)
    for _ in range(n):
        a, b = cache
        cache = (b, a + b)
    return cache[0]