Java Utililty Methods Factorial

List of utility methods to do Factorial

Description

The list of methods to do Factorial are organized into topic(s).

Method

longfactorial(int n)
factorial
return FACTORIALS[n];
intfactorial(int n)
Returns n!
int returnValue;
if (n < 0) {
    throw new IllegalArgumentException("Illegal value: " + n);
} else if ((n == 0) || (n == 1)) {
    returnValue = 1;
} else {
    returnValue = n * factorial(n - 1);
return returnValue;
doublefactorial(int n)
factorial
if (n < 0 || (n - (int) n) != 0)
    throw new IllegalArgumentException(
            "\nn must be a positive integer\nIs a Gamma funtion [gamma(x)] more appropriate?");
double f = 1.0D;
for (int i = 1; i <= n; i++)
    f *= i;
return f;
doublefactorial(int n)
factorial
return binomialCoefficient(n, 1);
intfactorial(int number)
A trivial recursive calculation of a number\'s factorial
if (number <= 1) {
    return 1;
} else {
    return number * factorial(number - 1);
intfactorial(int value)
factorial
if (value > 12) {
    throw new IllegalStateException("The value[" + value
            + "] is greater than 12 and anything equal to or larger than 13! is too large to be returned as an int.");
} else if (value < 0) {
    throw new IllegalStateException(
            "The value[" + value + "] is less than 0, so factorial cannot be computed.");
int result = 1;
...
doublefactorial(int x)
factorial
return Math.pow(10, log10Gamma(x + 1));
intFactorial(int x)
returns the factorial of a number
if (x == 0 || x == 1) {
    return 1;
} else if (x > 0) {
    int mul = 2;
    for (int i = 3; i <= x; i++) {
        mul *= i;
    return mul;
...
longfactorial(int x)
Calculates the factorial of x.
long result = 1;
while (x >= 1) {
    result *= x;
    x--;
return result;
longfactorial(long l)
Simple method to calculate the factorial of small values.
if (l <= 2)
    return l;
return l * factorial(l - 1);