I am working on calculating the amount of numbers between 1 and 10000 with a specific sum of digits using combinatorics. In the first problem, I have to find it for 9 and I did. I constituted the problem as a set containing 4-tuples of digits, with the condition that the elements of each tuple sum up to 9. And then I used (9 + 4 - 1) over 9 to solve it and the result is correct. But for 19, the same method is not working because the previous method also includes the cases where a coefficient is not a digit. I don't know how to continue and would appreciate any help.
-
Hope this helps you. https://math.stackexchange.com/q/2028849/1277478 – Vinay Karthik Feb 16 '24 at 09:30
1 Answers
This is a problem of balls in bins with limited capacity. You have $k=19$ balls to distribute over $m=4$ bins, all with capacity $R=9$. Thus, according to the last formula derived in the linked article, the number of distributions that satisfy the capacity constraints is
$$ \sum_{t=0}^4(-1)^t\binom4t\binom{4+19-10t-1}{4-1}=\binom{22}3-\binom41\binom{12}3=660\;, $$
where, contrary to the usual definition, binomial coefficients with negative upper index are taken to be zero.
In the present case, you don’t really need the full inclusion–exclusion machinery, as not more than one digit at a time can exceed its capacity, so to subtract out the inadmissible distributions from the initial count of $\binom{19+4-1}{4-1}=\binom{22}3$ you just have to choose one digit, $\binom41$, and count the distributions in which that digit exceeds its capacity. Since you need to use $10$ balls for that digit, you have $19-10=9$ balls left to distribute over the $4$ digits, which yields a count of $\binom{19-10+4-1}{4-1}=\binom{12}3$.

- 238,052