5 ONERRORGOTO1000
10 MODE8:DIM:ERASEa:DIMa(8):c$=CHR$(5):DEFCHR$(255)="82FE8280C0"
20 RESTORE400:FORi=0 TO8:READa(i):NEXT:x=1
30 CLS:PRINT"Gamma function (0<x≤70)";
50 LOCATE0,1:PRINTc$;"x =";x;"?";:INPUT@6;x:LOCATE0,0:IFx=<0 ORx>70 THEN50
70 x$=MID$(STR$(x),2)
80 LOCATE0,1:PRINTc$;"➃(";x$;") = .....";
100 IFx<1 THENy=x:GOSUB300:f=f/y:GOTO200
110 IFx=<5 THENy=x-INTx:GOSUB300:FORi=1TOx-1:f=f*(y+i):NEXT:GOTO200
150 f=EXP((x-.5)*LNx-x+.5*LN(2*PI)+1/12/x-1/360/x^3+1/1260/x^5-1/1680/x^7)
200 IFf THENf=ROUND(f,LOG(ABSf)-7)
210 PRINTc$;"➃(";x$;") =";f;:z$=INPUT$(1,@):GOTO50
300 f=a(0):FORi=1 TO8:f=f*y+a(i):NEXT:RETURN
400 DATA.035868343,-.193527818,.482199394,-.756704078,.918206857,-.897056937,.988205891,-.577191652,1
1000 IFERR=1 THENCLS:ONERRORGOTO0
1010 IFERL=50 THENRESUME50
1020 LOCATE0,1:PRINTc$;"not found";:z$=INPUT$(1,@):RESUME30