Skip to content

Instantly share code, notes, and snippets.

@MartinSvarrer
Created November 18, 2014 09:54
Show Gist options
  • Save MartinSvarrer/2cf2b3ee5f49b38b4752 to your computer and use it in GitHub Desktop.
Save MartinSvarrer/2cf2b3ee5f49b38b4752 to your computer and use it in GitHub Desktop.
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