Skip to content

Instantly share code, notes, and snippets.

@akiva
Created December 4, 2014 09:17
Show Gist options
  • Save akiva/3adced16d705d26111cd to your computer and use it in GitHub Desktop.
Save akiva/3adced16d705d26111cd to your computer and use it in GitHub Desktop.
function fibonacci(n) {
return (n < 2) ? n : fibonacci(n - 1) + fibonacci(n - 2);
}
// F0 = 0, F1 = 1, F2 = 1, F3 = 2, F10 = 55
for (var i = 1; i <= 10; i++) {
console.log(fibonacci(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment