BBS: Inland Empire Archive Date: 02-23-93 (20:11) Number: 238 From: MICHEL BERTLER Refer#: NONE To: SEAN SULLIVAN Recvd: NO Subj: Combinations & permutatio Conf: (2) Quik_Bas
Ok there you go! Guess I was too lazy at first glance to figure it out but the following GW-Basic program will solve your enigma! COMPERM.BAS ----------- 10 PRINT"PERMUTATIONS & COMBINATIONS" 20 DEFDBL A - Z:DEFSNG I,J,K 30 PRINT 40 PRINT"(Enter with no value to stop execution!)" 50 INPUT"Total number of elements";N 60 IF N = 0 THEN 270 70 INPUT"Group number of elements";D 80 IF D <= N THEN 120 90 PRINT"Group value too high!" 100 PRINT 110 GOTO 50 120 P = 1 130 C = 1 140 FOR I=N-D+1 TO N 150 IF 9.9E+37/I >= P THEN 180 160 PRINT"Overflow, more than 9.9E37 permutations!" 170 GOTO 50 180 P = P * I 190 NEXT I 200 FOR J=1 TO D 210 C = C * J 220 NEXT J 230 PRINT P;"permutations" 240 PRINT P/C;"combinations" 250 PRINT 260 GOTO 50 270 END
--- Michel --- GoldED * Origin: Blainville, Quebec (1:242/130)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET