Skip to content

Instantly share code, notes, and snippets.

@maksbd19
Created July 21, 2019 11:13
Show Gist options
  • Save maksbd19/fc87149dfdea663564c734ec19bb57f6 to your computer and use it in GitHub Desktop.
Save maksbd19/fc87149dfdea663564c734ec19bb57f6 to your computer and use it in GitHub Desktop.
function fibonacci(n){
// the base case: when the `n` is 1 or less then the number would be `1`
if(n <= 1){
return 1;
}
// otherwise we would want to get the previous
// two numbers and add them up.
return fibonacci(n-1) + fibonacci(n-2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment