Find the number of integers between 1 and 1 0 6 such that the sum of their digits is equal to 12.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
loved the way you excluded those extra cases .
Log in to reply
Thanks! It depends on the setup; the extra cases are easy to handle. If the digit sum exceeds 20, then it might be painful.
The solution is equal to the coefficient of x 1 2 in the expression ( x 0 + x 1 + x 2 + x 3 + x 4 + ⋯ + x 9 ) 6
You can make wolfram-alpha do the work by entering
expand (1+x+x^2+x^3+x^4+x^5+x^6+x^7+x^8+x^9)^6
and then picking out the coefficient of x 1 2 which is 6 0 6 2
Explanation
A little thought shows that the problem is equivalent to the number of compositions of 12 into 6 heaps with no heap being greater than 9, and with the possibility of some heaps being zero. The relationship between compositions and binomial-like coefficients is given here .
Great work!
Problem Loading...
Note Loading...
Set Loading...
Relevant wiki: Integer Equations - Stars and Bars
Let the number be
N = d 1 d 2 d 3 d 4 d 5 d 6
where 0 ≤ d i < 1 0 represents each digit. Note that leading 0 's is allowed as N can be any number between 1 and 1 0 6 . For example, 3 4 will be encoded as 0 0 0 0 3 4 .
We want the sum of digits equal to 12. In other words,
d 1 + d 2 + d 3 + d 4 + d 5 + d 6 = 1 2
The number of combinations of ( d 1 , d 2 , … , d 6 ) can be computed using the stars and bars technique, which gives ( 5 1 7 ) = 6 1 8 8 .
However, there are cases where d i ≥ 1 0 . We should remove these cases. Furthermore, there cannot be cases such that more than one digit is greater or equal to 10 because their sum will exceed 12. Hence the cases for each digit greater or equal to 10 is mutually exclusive. Suppose d 1 ≥ 1 0 , then we transform d 1 ′ = d 1 − 1 0
d 1 ′ + 1 0 + d 2 + d 3 + d 4 + d 5 + d 6 = 1 2 → d 1 ′ + d 2 + d 3 + d 4 + d 5 + d 6 = 2
Again by using the stars and bars technique, the number of combinations is ( 5 7 ) = 2 1 . Apply the same to all 6 digits and we have a total of 2 1 × 6 = 1 2 6 such cases. Hence the answer is
6 1 8 8 − 1 2 6 = 6 0 6 2