# $4$-digit numbers whose digit sum equal $10$?

How many $$4$$-digit numbers are there whose digit sum equals $$10$$?

For example, $$2017$$ is such a $$4$$-digit number.

I got this from a $$10$$th grade math competition review. I asked my algebra-$$2$$ teacher and she doesn't know how to solve it.

Reword this as finding the number of integer solutions to the system

$$\begin{cases} x_1+x_2+x_3+x_4=10\\ 1\leq x_1\color{grey}{\leq 9}\\ 0\leq x_2\color{grey}{\leq 9}\\0\leq x_3\color{grey}{\leq 9}\\ 0\leq x_4\color{grey}{\leq 9}\end{cases}$$

Ignoring the upper bound conditions for now, count the number of solutions to the above using a standard stars and bars argument.

Then, noticing that none of the upper bound conditions could possibly be violated for $x_2,x_3,x_4$ (while still satisfying the sum and all lower bounds), and only one outcome violates the first upper bound condition, subtract one to correct the overall count.

Change variable $x_1-1=y_1$ you have system $y_1+x_2+x_3+x_4=9$ and $0\leq y_1,0\leq x_i$. By stars and bars there are $\binom{9+4-1}{4-1}=\binom{12}{3}$ solutions ignoring upperbounds, making final total $\binom{12}{3}-1=220-1=219$

• I don't know if it's just my browser or an optical illusion, but for some reason the $\le 9$ bits are gray rather than the same color as the rest of the math text. (But not in my comment, apparently.)
– JAB
Apr 7, 2017 at 22:58
• @JAB: That's no illusion: the answer uses the MathJax code \color{grey} to get that color. I assume that reinforces the statement "Ignoring the upper bound conditions for now". Apr 7, 2017 at 23:38
• That was precisely my intention. In a more complicated problem, such as finding the number of four digit numbers whose digits add up to thirteen, the upper bounds will have been much more relevant, but as it turns out in this problem they are hardly noticed in the final solution. Apr 7, 2017 at 23:45