TwIsTeEeR wrote:
From a set of integers from 1 to 49,
take 6 unique integers,
that if we sum them up, this sum is equal to 150.
Conditions:
1. The set numbers are integers from 1 to 49
2. subset size is 6
3. sum of the selected subset numbers is 150
My questions:
A. How many sets (combinations) of 6 unique numbers exist that their sum
is 150?
B. Do you know of a function that can calculate that quantity
of combinations, for different values of conditions (1), (2), & (3)?
Thank you,
A mathematical answer came from:
The coefficient of s^6 t^150 in (1+st)(1+st^2)...(1+st^49).
Let P_0 = 1, and for j = 1 to 49 let
P_j = P_{j-1} (1+st^j) mod <s^7, t^151
(i.e. multiply it out and remove any term involving s^i with
i =7 or t^k with k = 151). In Maple you can do it with
P[0]:= 1;
for j from 1 to 49 do
P[j]:= rem(rem(P[j-1]*(1+s*t^j),s7,s),t151,t)
od:
coeff(coeff(P[49],t,150),s,6);
165772
A somewhat more prosaic dynamic-programming solution is also possible,
and would have faster execution time, but would require more time to
program.
Robert Israel
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
Is it posible to create a VBA function to satisfy the second question,
using the above answer?