Created
August 27, 2016 04:19
-
-
Save abalogun/d0b44dd1a4a1c861c9a9d55158f75c74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fib(n){ | |
var fib = []; | |
fib[0] = 1; | |
fib[1] = 1; | |
for(var i =2, i <= n; i++) { | |
fib[i] = fib[i - 1] + fib[i-2]; | |
} | |
return fib[i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
finally figured this one out (but my expressions look pretty crazy). the hint is: get the sequence started manually to avoid infinite loop, use your loop to .push items to your array, and then instead of using integers, use references to the numbers (by index of your new array ex: newArray[newArray.length - 1]) in your new array.
this one was really hard for me. if you want to see my solution let me know.