Last active
June 18, 2021 08:21
-
-
Save MiCkEyZzZ/1358d912a5dd1addfbfb7a33e302fdeb to your computer and use it in GitHub Desktop.
recursion
This file contains 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
const factorial = (n) => { | |
if (n === 1) { | |
return 1 | |
} | |
return n * factorial(n - 1) | |
} | |
const fibonacci = (n) => { | |
if (n === 1 || n === 2) { | |
return 1 | |
} | |
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