public static double logFactorial ( int n ) { if ( n < 0 ) { throw new IllegalArgumentException ( String . format ( "n has to be nonnegative: %d" , n ) ) ; } double f = 0.0 ; for ( int i = 2 ; i <= n ; i ++ ) { f += Math . log ( i ) ; } return f ; }
log of factorial of n