Last active
February 14, 2023 12:48
-
-
Save dcortesnet/fac9dc29ba54efe0603d3fb53067000a to your computer and use it in GitHub Desktop.
Javascript calcular el factorial de un número con recursividad
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 = (num) => { | |
if (num <= 1) { | |
return 1; | |
} | |
return num * factorial(num - 1); | |
} | |
console.log(factorial(5)); // 120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment