procedure GSER(var GAMSER:real; A:real; X:real; var GLN:real);
label 1;
const
ITMAX=100; EPS=0.3E-6;
var
N:Integer;
SUM,DEL,AP:Real;
begin
GLN:=GAMMLN(A);
If X If X < 0 Then
begin
ShowMessage('警告:X goto 1;
end
else
begin
GAMSER:=0;
goto 1;
end;
AP:=A;
SUM:=1 / A;
DEL:=SUM;
For N:=1 To ITMAX do
begin
AP:=AP + 1;
DEL:=DEL * X / AP;
SUM:=SUM + DEL;
If Abs(DEL) < Abs(SUM) * EPS Then GoTo 1;
end;
ShowMessage('A too large, ITMAX too small');
1: GAMSER:=SUM * Exp(-X + A * Ln(X) - GLN);
end;