about summary refs log tree commit diff
path: root/scratch/facebook/interview-cake/nth-fibonacci.py
blob: 4629798cf711d8dabd2d52f15aedd6fc2dc82735 (plain) (blame)
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]