Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created December 29, 2018 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5958a46d21f4d262fe30bb2bd73237d0 to your computer and use it in GitHub Desktop.
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
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