8-Bit Software Online Conversion

Combinations Example - Listing

10*| ** Combi ** 20*| Find 4 different positive intege rs a,b,c,d whose sum = N 30*| and the total number of possible sets, n. 40*| DP-J 30Nov94 50: 60MODE3 70VDU14 80PRINTTAB(30,3)"** Combi **" 90PRINT'TAB(12)"This program is refer red to in the text file EdCombi" 100REM PRINTTAB(22)" See *DIR$.Softwar e *TYPE EdCombi" 110PRINT'"Lists all values of 4 differ ent positive integers a,b,c,d which add up to N" 120INPUT''"What is total, N ? "N 130PRINT'TAB(9)"n a b c d" 140n=0 150REPEAT:a=a+1:b=a:c=a 160REPEAT:b=b+1:IFc=a c=c+1 170REPEAT:c=c+1 180 d=N-a-b-c 190 IFd>c n=n+1:PRINTn" ";a" ";b" "; c" ";d 200UNTILd<c:c=b+1 210UNTILd<c 220UNTILd<=0 230IF n>0 PRINT"Total of ";n" sets hav ing sum = ";N ELSE PRINT"Not possible"