Dana DeLouis wrote...
...
We are given 1,405,869 out of a possible 3,838,380.
We are first looking for x1 in {x1,_,_,_,_,_}.
We need to first sum the Combin's that don't exceed our number. We could
use code that works with the number (3838380 - 1405869), but we'll use
1405869 here.
Unfortunately, there is no Analytical solution to a Binomial Sum (Sum of
Excel's Combin function ) that allows a 1-liner for this particular
problem.
(AFAIK!).
Therefore, we have to resort to a Loop. (Ahh!)
...
Not necessarily.
Given N = 40, k = 6, fvseq defined as
=ROW(INDEX($1:$65536,1,1):INDEX($1:$65536,N-k+1,1))-1
(no volatile functions), and 1405869 in cell C7, x1 (in cell C8) is
given by the array formula
C8 [array formula]:
=MATCH(C7-1,MMULT(--(fvseq>=TRANSPOSE(fvseq)),
IF(fvseq,COMBIN(N+1-fvseq,COLUMNS(C$7:$H$7))
-COMBIN(N-fvseq,COLUMNS(C$7:$H$7)),0)))
The residual portion of q (in cell D7) is given by the array formula
D7 [array formula]:
=ROUND(C7-INDEX(MMULT(--(fvseq>=TRANSPOSE(fvseq)),
IF(fvseq,COMBIN(N+1-fvseq,COLUMNS(C$7:$H$7))
-COMBIN(N-fvseq,COLUMNS(C$7:$H$7)),0)),C8),0)
Rounding is necessary because Excel has a very nasty habit of returning
fractional values from COMBIN for various N and k values. The x2 value
(in cell D8) corresponding to this is given by the array formula
D8 [array formula]:
=MATCH(D7-1,IF(fvseq<N-COLUMNS(E$7:$H$7)-C8,
MMULT(--(fvseq>=TRANSPOSE(fvseq)),
IF(fvseq*(fvseq<N-COLUMNS(E$7:$H$7)-C8),
COMBIN(N+1-fvseq-C$8,COLUMNS(D$7:$H$7))
-COMBIN(N-fvseq-C$8,COLUMNS(D$7:$H$7)),0)),""))+C8
The next residual portion of q (in cell E7) is given by the array
formula
E7 [array formula]:
=ROUND(D7-INDEX(IF(fvseq<N-COLUMNS(E$7:$H$7)-C8,
MMULT(--(fvseq>=TRANSPOSE(fvseq)),
IF(fvseq*(fvseq<N-COLUMNS(E$7:$H$7)-C8),
COMBIN(N+1-fvseq-C$8,COLUMNS(D$7:$H$7))
-COMBIN(N-fvseq-C$8,COLUMNS(D$7:$H$7)),0)),""),D8-C8),0)
Fill E7 right into F7:H7, and fill D8 right into E8:G8. Complete this
by calculating x6 (in cell H8) with the simple formula
H8:
=G8+H7
Therefore, our KSubset is (3,12,17,24,32,36).
...
Yup.