Skip to content

Instantly share code, notes, and snippets.

@MinimumViablePerson
Last active December 31, 2019 11:59
Show Gist options
  • Save MinimumViablePerson/ec526ee99cf50ccb7d7d735e24d678b5 to your computer and use it in GitHub Desktop.
Save MinimumViablePerson/ec526ee99cf50ccb7d7d735e24d678b5 to your computer and use it in GitHub Desktop.
Recursion from Scratch - factorial
const factorial = number => {
// The factorial of 0 is: 1
if (number === 0) return 1
// The factorial of any other number is:
// that number times the factorial of the next number down
return number * factorial(number - 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment