Created
July 21, 2019 11:13
-
-
Save maksbd19/fc87149dfdea663564c734ec19bb57f6 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 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