Sub GCF(GAMMCF, A, X, GLN)
ITMAX = 100
EPS = 0.0000003
GLN = GAMMLN(A)
GOLD = 0#
A0 = 1#
A1 = X
B0 = 0#
B1 = 1#
FAC = 1#
For N = 1 To ITMAX
AN = N
ANA = AN - A
A0 = (A1 + A0 * ANA) * FAC
B0 = (B1 + B0 * ANA) * FAC
ANF = AN * FAC
A1 = X * A0 + ANF * A1
B1 = X * B0 + ANF * B1
If A1 0# Then
FAC = 1# / A1
G = B1 * FAC
If Abs((G - GOLD) / G) < EPS Then GoTo 1
GOLD = G
End If
Next N
Print "A too large, ITMAX too small"
1 GAMMCF = Exp(-X + A * Log(X) - GLN) * G
End Sub