![]() |
|
|||||||
| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
| Questions & Help Needed Post any question regarding Basic4ppc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi,
Related to my last question is the following. Does anyone have code to write out every possible combination (not permutation) from a given number X taken out Y (X choose Y)? Any help appreciated. i just cannot seem to get the appropriate number written out. Thx Marc |
|
|||
|
Try this link
http://en.wikipedia.org/wiki/Mathematical_combination as an example - to choose 3 out of 10 you have : 10! / (3! * (10-3)!) = 3628800/(6*5040) = 120 (calculated by SCalculator , since the only code you need is Factorial function, you can find it there.)
__________________
David Erez Ramat Hasharon, Israel |
|
|||
|
Here is conceptual code, not debugged:
sub combination(x,y) a = 1 for i = 1 to x a = a*i next b = 1 for i = 1 to y b=b*i next c=1 for i = 1 to x-y c= c*i next return a/(b*c) end sub
__________________
David Erez Ramat Hasharon, Israel |
|
|||
|
Okay, I took the challenge !
see the attached program, both displaying and storing in a file. fill the a out of b and press go. you will get the number of combinations and the last one, and you can brouse up and down. ![]()
__________________
David Erez Ramat Hasharon, Israel Last edited by derez : 02-04-2008 at 06:27 AM. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Write IF error | GallyHC | Questions & Help Needed | 4 | 06-02-2008 05:42 PM |
| Choose Folder - Optimized Compilation | orhan | Questions & Help Needed | 9 | 05-15-2008 02:36 PM |
| Combinations Sub: choose(n,k) | Stellaferox | Code Samples & Tips | 2 | 02-21-2008 06:51 PM |
| Combinations function | derez | Share Your Creations | 0 | 02-04-2008 11:40 AM |
| Tip on how not to write speedy code | kolbe | Code Samples & Tips | 1 | 01-30-2008 08:20 AM |