Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 2, 2019 00:13
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/f9e09d2722cd0284c0c6b22caddc65aa to your computer and use it in GitHub Desktop.
Save parzibyte/f9e09d2722cd0284c0c6b22caddc65aa to your computer and use it in GitHub Desktop.
/**
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