# How many ten digit numbers have the sum of their digits equal to $4$?

How many ten digit numbers have the sum of their digits equal to $$4$$? Well, my solution goes like this:

The first digit of the $$10$$ digit number cannot be $$0$$. It can be $$1,2,3$$ or $$4$$ only . If the first digit is $$1$$ then we can have $$3$$ other digits as $$1$$ so as the sum of digit is $$4$$ . This can be done in $$9\choose3$$ ways . Now when the 1st digit is $$1$$ then we can have two digits $$2$$ and $$1$$ as another case such as sum of digit remains $$4$$. So, this can be done in $$9\choose 2$$ ways . Now, another case can be the one when 1st digit is $$4$$ but another digit is $$3$$ . This can be done in $$9\choose 1$$ ways . So the number of ways when 1st digit is $$1$$ is $$9\choose3+9\choose2+9\choose1$$ways. Now, if the 1st digit is $$2$$ then the other two digits can be $$1$$ each . This can done in $$9\choose2$$ways . If the 1st digit is $$2$$ the other digit can be $$2$$ . This can be done in $$9\choose1$$ways.The total of ways this can be done is $$9\choose2+9\choose1$$ ways. If the 1st digit is $$3$$ then another digit among those $$9$$ digits must be $$1$$.this can be done in $$9\choose1$$ways. If the 1st digit is $$4$$ then all the other digits are zero . This can be done in $$1$$ way only. So, the total number of ways in which the sum of digits can be $$4$$ in a $$10$$ - digit number is $$9\choose3+9\choose2+9\choose1+9\choose2+9\choose1+$$ $$9\choose1+1$$ ways$$=184$$ways

However the answer in the book is given as: $$1+29\choose 1+9\choose1+9\choose23!/2!+9\choose 3=220$$ways

Where is the mistake? Where is the problem occuring?

• The correct answer is $\binom{12}{3} = 220$, which can be demonstrated using the stars and bars method. Your error is when you consider the case where the first digit is 1 and there is also a 2. There are not $\binom{9}{2}$ ways of doing this; there are $P^9_2$ ways, since which digit is a 2 and which a 1 matters. Apr 23, 2022 at 4:07
• Related and this too.
– user983440
Apr 23, 2022 at 4:09
• @Yooo yes...but I wanted to verify my solution...
– user992622
Apr 23, 2022 at 4:10
• @MarkSaving Thanks a lot! I do get it now...
– user992622
Apr 23, 2022 at 4:12
• You added incorrectly. The expression you obtained adds to $184$. Since $P(9, 2) = 2\binom{9}{2}$, adding $\binom{9}{2}$ to $184$ does give the correct answer of $220$. Apr 23, 2022 at 9:42

As Mark Saving pointed out in the comments, the error you made was not taking into account the order of the digits $$1$$ and $$2$$ in numbers in the case in which the leading digit is $$1$$ and the other nonzero digits are $$1$$ and $$2$$. In that case, there are $$9$$ ways to place the second $$1$$ and eight ways to place the $$2$$. With that correction, you would have obtained $$220$$ rather than $$184$$ since $$P(9, 2) - \binom{9}{2} = 9 \cdot 8 - 36 = 36$$.
Here is another approach to the problem. Let $$x_i$$ be the $$i$$th digit. Then $$x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 + x_9 + x_{10} = 4 \tag{1}$$ Since the leading digit cannot be zero, the integer $$x_1 \geq 1$$. Each of the remaining variables represents a nonnegative integer.
Let $$x_1' = x_1 - 1$$. Then $$x_1'$$ is also a nonnegative integer. Substituting $$x_1' + 1$$ for $$x_1$$ in equation 1 yields \begin{align*} x_1' + 1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 + x_9 + x_{10} & = 4\\ x_1' + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 + x_9 + x_{10} & = 3 \tag{2} \end{align*} Equation 2 is an equation in the nonnegative integers. A particular solution of equation 2 corresponds to the placement of $$10 - 1 = 9$$ addition signs in a row of $$3$$ ones. For instance, $$+ + 1 + + + + 1 1 + + +$$ corresponds to the solution $$x_1' = x_2 = 0$$, $$x_3 = 1$$, $$x_4 = x_5 = x_6 = 0$$, $$x_7 = 2$$, $$x_8 = x_9 = x_{10} = 0$$ (in which case, the original number was $$10,010,002,000$$ since $$x_1 = x_1' + 1$$). The number of solutions of equation 2 is the number of ways we can insert $$10 - 1 = 9$$ addition signs in a row of $$3$$ ones, which is $$\binom{3 + 10 - 1}{10 - 1} = \binom{12}{9} = 220$$ since we must choose which nine of the twelve positions required for three ones and nine addition signs will be filled with addition signs.