Yet another factorial approx function

(*) not bat at all – enjoy!

function crfac(i:byte):real;
var
j: byte;
begin
j:=i;
crfac:=(j-1/2.71828459);
for i:=1 to j-1 do begin
crfac:=crfac*i;
end;
end;

begin
writeln(crfac(1):8:0);
writeln(crfac(2):8:0);
writeln(crfac(3):8:0);
writeln(crfac(4):8:0);
writeln(crfac(5):8:0);
writeln(crfac(6):8:0);
writeln(crfac(7):8:0);
writeln(crfac(8):8:0);
writeln(crfac(9):8:0);
end.

Advertisements