Created
November 18, 2014 09:54
-
-
Save MartinSvarrer/2cf2b3ee5f49b38b4752 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) { | |
return (n >= 2) ? fib(n-1) + fib(n-2) : n; | |
} | |
// Example of getting Nth fibonacci number | |
fib(10); | |
// Generate a sequense of fibonacci | |
for (var i = 0; i < 20; i++) { | |
console.log(fib(i)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment