by
4,027 20

Fibonacci meh

Loops over the Fibonnaci sequence...might be useful in an interview.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/3652194/Fibonacci-meh?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
function fibonacci(num, memo) { memo = memo || {}; return memo[num]? memo[num]: num < 2? 1: memo[num] = fibonacci(num - 1, memo) + fibonacci(num - 2, memo); } for(var i=0;i<100;i=i+1){ this.console.log(fibonacci(i)); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus