Skip to content

Instantly share code, notes, and snippets.

@MiCkEyZzZ
Last active June 18, 2021 08:21
Show Gist options
  • Save MiCkEyZzZ/1358d912a5dd1addfbfb7a33e302fdeb to your computer and use it in GitHub Desktop.
Save MiCkEyZzZ/1358d912a5dd1addfbfb7a33e302fdeb to your computer and use it in GitHub Desktop.
recursion
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