Created
December 29, 2018 03:06
-
-
Save parzibyte/5958a46d21f4d262fe30bb2bd73237d0 to your computer and use it in GitHub Desktop.
Factorial en JavaScript con recursividad created by parzibyte - https://repl.it/@parzibyte/Factorial-en-JavaScript-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 = numero => { | |
// Sacar valor absoluto | |
numero = Math.abs(numero); | |
if (numero <= 1) return 1; | |
return numero * factorial(numero - 1); | |
}; | |
for (let x = 0; x < 10; x++) { | |
console.log(`El factorial de ${x} es ${factorial(x)}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment