S Stellaferox Active Member Licensed User Feb 3, 2008 #1 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
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
derez Expert Licensed User Longtime User Feb 3, 2008 #2 combination 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.)
combination 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.)
derez Expert Licensed User Longtime User Feb 3, 2008 #3 combination 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
combination 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
S Stellaferox Active Member Licensed User Feb 3, 2008 #4 thnx guys, but I need the code for writing out the different combinations.
derez Expert Licensed User Longtime User Feb 4, 2008 #5 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. Last edited: Feb 4, 2008
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.