home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / sys / ibm / pc / misc / 14918 < prev    next >
Encoding:
Text File  |  1992-11-23  |  1.1 KB  |  35 lines

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