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

  1. Newsgroups: comp.sys.ibm.pc.misc
  2. Path: sparky!uunet!noc.near.net!vaxeline.ftp.com!AltaHopa.ftp.com!plummer
  3. From: plummer@vax  (William W. Plummer)
  4. Subject: Re: 'All Possible Combinations' Algorithm
  5. Message-ID: <921123105513@AltaHopa.ftp.com>
  6. Nntp-Software: PC/TCP NNTP
  7. Lines: 19        
  8. Sender: root@vaxeline.ftp.com (vaxeline.ftp.com root account)
  9. Nntp-Posting-Host: altahopa.ftp.com
  10. Reply-To: plummer@babyoil.ftp.com
  11. Organization: FTP Software, Inc., Wakefield, MA
  12. References: <By10r6.I64@apollo.hp.com>
  13. Date: Mon, 23 Nov 1992 10:55:13
  14.  
  15. In article <By10r6.I64@apollo.hp.com> holbrook@apollo.HP.COM (Alan R. Holbrook) writes:
  16.  
  17.  >Can someone provide me with an algorithm suitable for writing a program
  18.  >to dump all possible combinations of 'n' elements taken 'm' at a time?
  19.  
  20. n!/(m! * (n-m)!)
  21.  
  22. For instance in the MA Megabucks with 6 numbers out of 36 we have
  23.  
  24. 36!(6! * 30!)  =  36*35*34*33*32*31/(6*5*4*3*2*1)
  25.         = 6*7*34*11*4*31
  26.         = 1,947,792
  27.  
  28. --Bill
  29.  
  30. --
  31. William W. Plummer, N1NGK    plummer@ftp.com      --->    508-659-6281
  32. FTP Software, Inc.        2 High Street        N. Andover MA 01845
  33.  
  34.  
  35.