private double logFac(double x){
  double result=0;
  for (double i=2; i <= x; i++) {
    result+=Math.log(i);
  }
  return result;
}

private double logFac ( double x ) { double result = 0 ; for ( double i = 2 ; i <= x ; i ++ ) { result += Math . log ( i ) ; } return result ; }
calculates the log factorial of a number .
