home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.ibm.pc.misc
- Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!news
- From: spagiola@frinext.stanford.edu (Stefano Pagiola)
- Subject: Re: 'All Possible Combinations' Algorithm
- Message-ID: <1992Nov23.164311.27333@leland.Stanford.EDU>
- Sender: news@leland.Stanford.EDU (Mr News)
- Reply-To: spagiola@frinext.stanford.edu
- Organization: DSO, Stanford University
- References: <921123105513@AltaHopa.ftp.com>
- Date: Mon, 23 Nov 92 16:43:11 GMT
- Lines: 22
-
- William W. Plummer writes
- >> Can someone provide me with an algorithm suitable for writing
- >> a program to dump all possible combinations of 'n' elements
- >> taken 'm' at a time?
- >
- > n!/(m! * (n-m)!)
- >
- > For instance in the MA Megabucks with 6 numbers out of 36 we have
- >
- > 36!(6! * 30!) = 36*35*34*33*32*31/(6*5*4*3*2*1)
- > = 6*7*34*11*4*31
- > = 1,947,792
-
- Methinks the original poster wanted to _list_ all possible
- combinations, not just calculate how many there are...
-
- --
- -
- Stefano Pagiola
- Food Research Institute, Stanford University
- spagiola@frinext.stanford.edu (NeXTMail encouraged)
- spagiola@FRI-nxt-Pagiola.stanford.edu (NeXTMail encouraged)
-