Skip to content

Instantly share code, notes, and snippets.

@alexeykomov
Created December 10, 2015 14:08
Show Gist options
  • Save alexeykomov/d659a0fb14c2ae6a66c6 to your computer and use it in GitHub Desktop.
Save alexeykomov/d659a0fb14c2ae6a66c6 to your computer and use it in GitHub Desktop.
Fibonacci number generation with recursive function.
function fibonacci(index) {
if (index == 0) {
return 0;
} else if (index == 1) {
return 1;
} else {
return fibonacci(index - 2) +
fibonacci(index - 1)
}
}
fibonacci(0);
fibonacci(1);
fibonacci(2);
fibonacci(3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment