3 ms·
I'm confused by the corrected diff in the README... isn't that cache recreated on each function call to fib(), making the cache pointless?
by torrance 6y ago
I'm confused by the corrected diff in the README... isn't that cache recreated on each function call to fib(), making the cache pointless?
- celrod 6y agoIt is recreated on every call to `fib`, but the `_fib`s get to reuse it. Using a cache makes `_fib` O(N) to compute, so it gives a performance benefit as long as you aren't calling `fib(n)` with very small values of `n`.