code: public static final double gammaln(double x) {
  		double ser = 1.00000000090015;
  		double y = x;
  		double tmp = x + 5.5;
  		tmp -= (x + 0.5) * Math.log(tmp);
  		for (int j = 0; j < 5; j++) {
  			ser += COFGAMMALN[j] / ++y;
  		}
  		return -tmp + Math.log(ser * 2.5066282751072975 / x);
  	}
docs: from numerical recipes in c (p. 214)