Created
December 29, 2018 03:09
Star
You must be signed in to star a gist
Factorial de un número con BigInt
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 => { | |
if (numero < 0n) numero = numero * -1n; | |
if (numero <= 0n) return 1n; | |
let factorial = BigInt(1); | |
while (numero > 1) { | |
factorial = factorial * numero; | |
numero--; | |
} | |
return factorial; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment