Package com.helger.commons.math
Class FactorialHelper
- java.lang.Object
-
- com.helger.commons.math.FactorialHelper
-
@Immutable public final class FactorialHelper extends Object
Smart class for calculating factorials.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static intPREDEFINED_MAX_INDEXThe maximum value for which pre-computed factorial values are presentstatic intPREDEFINED_MIN_INDEXThe minimum value for which pre-computed factorial values are present
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BigIntegergetAnyFactorialLinear(int n)static longgetSmallFactorial(int n)Calculate n!
-
-
-
Field Detail
-
PREDEFINED_MIN_INDEX
public static final int PREDEFINED_MIN_INDEX
The minimum value for which pre-computed factorial values are present- See Also:
- Constant Field Values
-
PREDEFINED_MAX_INDEX
public static final int PREDEFINED_MAX_INDEX
The maximum value for which pre-computed factorial values are present
-
-
Method Detail
-
getSmallFactorial
@Nonnegative public static long getSmallFactorial(@Nonnegative int n)
Calculate n! whereas n must be in the range of 0 toPREDEFINED_MAX_INDEX.- Parameters:
n- Input value- Returns:
- The factorial value.
-
getAnyFactorialLinear
@Nonnull public static BigInteger getAnyFactorialLinear(@Nonnegative int n)
-
-