public static BigDecimal factorial ( int n ) { if ( n < 0 ) { throw new ArithmeticException ( "Illegal factorial(n) for n < 0: n = " + n ) ; } if ( n < factorialCache . length ) { return factorialCache [ n ] ; } BigDecimal result = factorialCache [ factorialCache . length - 1 ] ; return result . multiply ( factorialRecursion ( factorialCache . length , n ) ) ; }
Calculates the factorial of the specified integer argument .