Created
February 2, 2019 00:13
-
-
Save parzibyte/f9e09d2722cd0284c0c6b22caddc65aa 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
/** | |
Factorial iterativo con ciclo while | |
en Java | |
@author parzibyte | |
*/ | |
public static long factorial(long numero) { | |
if (numero < 0) | |
numero = numero * -1; | |
if (numero <= 0) | |
return 1; | |
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