Math and computer program question

pouradam

New member
Joined
Apr 29, 2011
Messages
3
Good day all!

My question is sort of a Math/Computer question.... If you could just tell me the Math process I should follow to reach the answer, I will make the program.

There is an Array named C contains 100 different numbers :
For Example:
C(1) = 142
C(2) = 876
C(3) = 64
...
C(100) = 7124

I want to calculate how many possible combinations we can have contains 10 Numbers (out of those 100 numbers).

For Example:
Lets have a look at a smaller example. If array C contains 5 digits as follows:

C(1) = A
C(2) = B
C(3) = C
C(4) = D
C(5) = E

How many Cmbination of 3 Digits we can have ?
Answer:

ABC / ABD / ABE / ACD / ACE / ADE / BCD / BCE / CDE / BDE .. ?

But what is the process for finding above combinations I don't know!

Hope my question is clear? I appreciate if anyone could help me find the formula .
My final aim is to use this formula for a program in Excel (VBScript).

Take care all! thanks for reading :wink:
 
Simple.

N = Available numbers
n = Those you will select.

Total possible: \(\displaystyle N^{n}\)

I hope you've lots of RAM.
 
The answer depends on the statement of the problem.

Can a number in the array be used more than once? That is, if you are to choose 2 numbers out of an array with 5 numbers and can use a number more than once, there are 5 ways to choose the first time and 5 ways to choose the second time, meaning a total of 5^2 = 25, just as tkhunny said. More generally N[sup:22c8ptjr]n[/sup:22c8ptjr], where n is the number of numbers to be chosen and N is the the number of numbers in the array.

If, however, you are not supposed to use a number twice but are supposed to distinguish between getting a first, b second and b first, a second, then you can choose the first number 5 ways and the second 4 ways so the answer is 20 ways in total. THAT formula is [5! / (5 - 2)!], or more generally
[N! / (N - n)!]. Do you understand?

If, moreover, you are not supposed to use a number twice and are not supposed to distinguish between getting a first, b second and b first, a second, there are 10 ways, namely, a and b (any order), a and c, a and d, a and e, b and c, b and d, b and e, c and d, c and e, and finally d and e. THAT formula is
{5! / [(5 - 2)! * 2!]} or more generally {N! / [(N - n)! * n!]}. Do you understand?

If there are additional constraints, still yet another formula will be required. In general, the more constarints, the smaller the answer will be.

Your problem as you gave it to us is not well defined.
 
Hello, pouradam!

There is an Array named C contains 100 different numbers :

For example: .C(1) = 142, C(2) = 876, C(3) = 64, . . . C(100) = 7124

I want to calculate how many possible combinations we can have contains 10 Numbers (out of those 100 numbers).

Assuming that there is no repetition allowed and that the order of the numbers is not important,
. . this is a Combination problem.
\(\displaystyle \text{The number of combinations is: }\;_{100}C_{10} \;=\;{100\choose10} \;=\;\frac{100!}{10!\,90!} \;\approx\;1.6 \times 10^{12}\)


Printing 1000 combinations per second, it will take over 50 years to print the entire list.

Printing 100 combinations to an inch, the list will be stretch beyond the Moon..

Have fun!

 
Thank you all for all your great answers!
Thanks "soroban" for your awesome comparisons!
Thanks "tkunny" for the first reply.

And dear JeffM! Your great explanation in details, helped me a lot!!
And sorry that my problem was not well defined.

Based on your given information, in my case the correct formula I need would be :

{N! / [(N - n)! * n!]}

But one main problem still remains! with this formula, I can Just calculate the total number of possibilities. right?

What I plan to do is making a program in computer that could work similar to this:

[Program Input]

1- Input Number of Cells? (User Enters "5" for example)
2- Input Number of Combinations? (User Enters "2" for example)

[Program Output]

Possible Combinations are:
ab - ac - ad - ae - bc - bd - be - cd - ce - de.

(Note it was a similar example - the real program instead of generating ab , ac , ...
generates the "values" saved in Array C. means instead of "ab" as the 1st possibility,
It will generate the value saved in C(1) and C(2) . means if C(1)=100 and C(2)=200
Then instead of "ab" , it will generate "300" (means 100+200) )

Maybe if you could offer me a URL that I could find the proof of that formula in there, I can follow the proof step by step and try to find out a solution to program it.

What is YOUR idea dear math experts?

Once again....Thanks all! you helped me a lot.
 
pouradam said:
Thank you all for all your great answers!
Thanks "soroban" for your awesome comparisons!
Thanks "tkunny" for the first reply.

And dear JeffM! Your great explanation in details, helped me a lot!!
And sorry that my problem was not well defined.

Based on your given information, in my case the correct formula I need would be :

{N! / [(N - n)! * n!]}

But one main problem still remains! with this formula, I can Just calculate the total number of possibilities. right?

What I plan to do is making a program in computer that could work similar to this:

[Program Input]

1- Input Number of Cells? (User Enters "5" for example)
2- Input Number of Combinations? (User Enters "2" for example)

[Program Output]

Possible Combinations are:
ab - ac - ad - ae - bc - bd - be - cd - ce - de.

(Note it was a similar example - the real program instead of generating ab , ac , ...
generates the "values" saved in Array C. means instead of "ab" as the 1st possibility,
It will generate the value saved in C(1) and C(2) . means if C(1)=100 and C(2)=200
Then instead of "ab" , it will generate "300" (means 100+200) )

Maybe if you could offer me a URL that I could find the proof of that formula in there, I can follow the proof step by step and try to find out a solution to program it.

What is YOUR idea dear math experts?

Once again....Thanks all! you helped me a lot.

First, I am NOT a math EXPERT. My academic training was in history. But I remember vividly my own problems in grasping certain mathematical ideas so I am familiar with what certain stumbling blocks are. tkhunny and soroban are the experts. By the way, you should reread my first post. There was a typogrphical error, which I have now fixed, but it was very misleading as originally posted.

Second, I was professionally a programmer for a number of years, but that was decades ago, and the only computer language whose syntax I remember is FORTRAN. So I was not able to decipher your code.

Third, I did not find a site that gives a good proof of the formulas for combinations and permutations. Probably a good introductory text on probability theory will have one.

Fourth, it may not take long to WRITE a program to do what you want to do, but, given the size of array that you are thinking about, it will take a very long time to RUN the program. That was part of what tkhunny and soroban were saying to you. If the program is going to be practical for arrays of 100 numbers and sums of up to 10 addends, you need additional constraints for the program to finish running this semester. Of course, you can write the program for numbers this large and test it for smaller values in some reasonable amount of time.
 
If I follow what you're trying to do:
as example, we have array A size 5 with: A(1)=2, A(2)=5, A(3)=6, A(4)=8, A(5)=10 ;
and we want to find the sum of all combos of 3 ;
so N=5 and n=3 ; which means 10 combos: 5!/ (2! * 3!) = 10

To find 'em all, you'd need a "looper program", a bit like:

loop a from 1 to N-n+1 [that's 1 to 3]
loop b from a+1 to N-n+2 [that's 2 to 4]
loop c from b+1 to N-n+3 [that's 3 to 5]

s = A(a) + A(b) + A(c) [get the sum ; 1st will be 2+5+6 = 13]
print a,b,c,s

Endloops.

And this will be the print output:
1,2,3,13
1,2,4,15
1,2,5,17
1,3,4,16
1,3,5,18
1,4,5,20
2,3,4,19
2,3,5,21
2,4,5,23
3,4,5,24

Correct?
If so, then the total combos (10 in this example) is a "nice to know type thing",
but is really not required, as the "looper program" does not need this information.
 
Dear Denis!!! You did it, thank you so muchhh.... :D

Have a great day ahead.

Yours,
Ali
 
Top