private double gcf(double x, double a) {
		int i;
		double gold = 0, g, a0 = 1, a1 = x, b0 = 0, b1 = 1, fac = 1, anf, ana;

		for (i = 1; i <= ITER_MAX; i++) {
			ana = i - a;
			a0 = (a1 + a0 * ana) * fac;
			b0 = (b1 + b0 * ana) * fac;
			anf = i * fac;
			a1 = x * a0 + anf * a1;
			b1 = x * b0 + anf * b1;
			if (a1 != 0.0) {
				fac = 1 / a1;
				g = b1 * fac;
				if (Math.abs((g - gold) / g) < EPS)
					return (g * Math.exp(-x + a * Math.log(x) - logGamma(a)));
				gold = g;
			}
		}
		return 2; // gamcdf will return -1
	}