10 PRINT "CHI-SQUARE DISTRIBUTION"
20 PRINT
30 PRINT "(TO END PROGRAM ENTER 0)"
40 PRINT "DEGREES OF FREEDOM";
50 INPUT V
60 IF V=0 THEN 280
70 PRINT "CHI-SQUARE";
80 INPUT W
89 REM -R=THE DENOMINATOR PRODUCT
90 R=1
100 FOR I=V TO 2 STEP -2
110 R=R*I
120 NEXT I
129 REM - K=THE NUMBERATOR PRODUCT
130 K=W[(INT((V+1)/2))*EXP(-W/2)/R
139 REM - THE PI FACTOR IS USED ONLY WHEN DEG. FREEDOM ARE ODD
140 IF INT(V/2)=V/2 THEN 170
150 J=SQR(2/W/3.141592653599)
160 GOTO 180
169 REM - L (SUMMATION FACTOR) CALCULATED LINES 170-240
170 J=1
180 L=1
190 M=1
200 V=V+2
210 M=M*W/V
219 REM - CHECK FOR END OF SUMMATION
220 IF M<.0000001 THEN 250
230 L=L+M
240 GOTO 200
250 PRINT "TAIL END VALUE =";1-J*K*L
260 PRINT
270 GOTO 40
280 END
