Last active
December 31, 2019 11:59
-
-
Save MinimumViablePerson/ec526ee99cf50ccb7d7d735e24d678b5 to your computer and use it in GitHub Desktop.
Recursion from Scratch - factorial
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
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