Created
December 3, 2019 05:37
-
-
Save parzibyte/3d3796d85ca1aa85187d3eb612f0b389 to your computer and use it in GitHub Desktop.
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
unsigned long long factorial(unsigned long long numero) { | |
// Convertir a positivo si es necesario | |
if (numero < 0) | |
numero = numero * -1; | |
// Si es 0, el factorial es 1 | |
if (numero == 0) | |
return 1; | |
// Si ninguna condición anterior se cumple, multiplicamos | |
unsigned long long factorial = 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