public static double logFactorial(int n){
  if (n < 0)   throw new IllegalArgumentException();
 else   if (n <= 1)   return 0;
 else   return (n * Math.log(n)) - n + (0.5 * Math.log(2 * Math.PI * n));
}

public static double logFactorial ( int n ) { if ( n < 0 ) throw new IllegalArgumentException ( ) ; else if ( n <= 1 ) return 0 ; else return ( n * Math . log ( n ) ) - n + ( 0.5 * Math . log ( 2 * Math . PI * n ) ) ; }
ln ( n ! ) . implemented as stirling ' s approximation .
