RSSAmplifier

OranLooney.com · Feb 19, 2019

A Fairly Fast Fibonacci Function

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

A common example of recursion is the function to calculate the $n$-th Fibonacci number: def naive_fib(n): if n < 2: return n else: return naive_fib(n-1) + naive_fib(n-2) This follows the mathematical definition very closely but it&rsquo;s performance is terrible: roughly $\mathcal{O}(2^n)$. This is commonly patched up with dynamic programming.

Read on oranlooney.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.