diff --git a/scratch/facebook/interview-cake/nth-fibonacci.py b/scratch/facebook/interview-cake/nth-fibonacci.py new file mode 100644 index 000000000..4629798cf --- /dev/null +++ b/scratch/facebook/interview-cake/nth-fibonacci.py @@ -0,0 +1,6 @@ +def fib(n): + cache = (0, 1) + for _ in range(n): + a, b = cache + cache = (b, a + b) + return cache[0]