10 PRINT "PERMUTATIONS AND COMBINATIONS"
20 PRINT
30 PRINT "(ENTER O TO END PROGRAM)"
40 PRINT "TOTAL NUMBER OF OBJECTS";
50 INPUT N
59 REM - TEST FOR END OF PROGRAM
60 IF N=0 THEN 280
70 PRINT "SIZE OF SUBGROUP";
80 INPUT D
89 REM - SIZE OF SUBGROUP CANNOT BE LARGER THAN SIZE OF GROUP
90 IF D<=N THEN 130
100 PRINT "SUBGROUP TOO LARGE"
110 PRINT
120 GOTO 40
129 REM - LINES 130 TO 200 COMPUTE PERMUTATIONS
130 P=1
140 C=1
150 FOR I=N-D+1 TO N
159 REM - DON'T ALLOW NUMBER SIZE TO OVERFLOW MACHINE CAPACITY
160 IF 1.7E38/I>=P THEN 190
170 PRINT "MORE THAN 1.7E38 PERMUTATIONS"
180 GOTO 280
190 P=P*I
200 NEXT I
209 REM - COMPUTE INTERMEDIATE FACTORIAL FOR COMBINATIONS
210 FOR J=2 TO D
220 C=C*J
230 NEXT J
240 PRINT P;"PERMUTATIONS"
250 PRINT P/C;"COMBINATONS"
260 PRINT
269 REM - RESTART PROGRAM
270 GOTO 40
280 END
