Mark Wickens

5 ONERRORGOTO500
10 MODE8:DIM:c$=CHR$(5)
20 CLS:PRINT"Kn(x)         (0≤n≤9,0<x≤10)";
30 LOCATE0,1:PRINTc$;"n?   :x?      :K=";
40 LOCATE2,1:INPUT@3;n$:LOCATE0,0:n=VALF(LEFT$(n$,3)):u=ABSn:IFn<0 ORu>=10 ORFRACu<>0 THEN450
60 LOCATE8,1:INPUT@6;x$:LOCATE0,0:x=VALF(LEFT$(x$,6)):v=ABSx:IFx=<0 ORv>10 THEN460
80 LOCATE17,1:PRINT" .....";:GOSUB200
100 IFx<0 THENr=r*(-1)^u
110 IFr<>0 ANDABSr>=1e-90 THENr=ROUND(r,LOG(ABSr)-7)
115 IFr<>0 ANDABSr<1e-90 THENr=r*1e10:r=ROUND(r,LOG(ABSr)-7):r=r/1e10
120 LOCATE18,1:PRINT"     ";:LOCATE17,1:PRINTr;:z$=INPUT$(1,@):GOTO30
200 IFv>2 THEN400
210 c=0:b=1E-99:s=0
220 FORk=11 TO0 STEP-1:a=2*(k+1)*b/v+c:s=s+a:c=b:b=a:NEXT
230 s=2*s-a:d=a/s*EXP(v)
240 w=v/2:e=-LN(w)*d-.5772157+.4227842*w^2+.2306976*w^4+.0348859*w^6+.002627*w^8+.0001075*w^10+.0000074*w^12
250 IFn=0 THENr=e:RETURN
260 f=(c/s)*EXP(v):g=(1/v-f*e)/d
270 IFu=1 THENr=g:RETURN
300 a=e:b=g
310 FORi=1 TOu-1:c=2*i*b/v+a:a=b:b=c:NEXT
320 r=c:RETURN
400 w=2/v:e=(1.2533141-.0783236*w+.0218957*w^2-.0106245*w^3+.0058787*w^4-.0025154*w^5+.0005321*w^6)*EXP(-v)/SQRv
410 IFn=0 THENr=e:RETURN
420 g=(1.2533141+.2349862*w-.0365562*w^2+.0150427*w^3-.0078035*w^4+.0032561*w^5-.0006825*w^6)*EXP(-v)/SQRv
430 IFu=1 THENr=g:RETURN
440 GOTO300
450 LOCATE2,1:PRINT"   ";:GOTO40
460 LOCATE8,1:PRINT"      ";:GOTO60
500 IFERR=1 THENCLS:ONERRORGOTO0
510 IFERL=40 THENRESUME450
520 IFERL=60 THENRESUME460
530 LOCATE17,1:PRINT"not found";:z$=INPUT$(1,@):RESUME20