by EpicDavi · 12y ago · 0 comments
The Fibonacci code example classically has a horrid runtime. Will like likely crash your browser when supplied a number higher than the low thirties. IIRC it has a O(2^n) runtime and can be improved either by a bottom up approach (non-recursive) or a "dynamic-programming" (OOohhhh, buzzwords) method where you use memoization (memo table) to store (or memoize) results.
Unless looping and counting is that much faster than doing some floating point math?
EDIT: Tied with JadeNB (https://news.ycombinator.com/item?id=8555051).
So close, and only ngorenflo (https://news.ycombinator.com/item?id=8555050) can come between us. :-)
EDIT: Tied with Mithrandir (https://news.ycombinator.com/item?id=8555049).