# How many positive integers <1,000,000,000 have exactly one digit equal to 9 and have the sum of digits equal to 13?

How many positive integers $$<1,000,000,000$$ have exactly one digit equal to $$9$$ and have the sum of digits equal to $$13$$?

I have:

$$x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 + 9 = 13$$

$$x_1 + x_2 + x_3 + x_4 + x_5 + x_6 + x_7 + x_8 = 4$$

Then I use $${{n+k-1}\choose k}$$:

$${11\choose 4}$$ = 330

Then $$330*9 = 2970$$.

So there are $$2970$$ integers that satisfy the problem.

My questions:

First, is this correct?

Second, why/when should I use $${{n+k-1}\choose k}$$ over $${{n+k-1}\choose k-1}$$

Third, when using the stars and bars approach, would this be a correct example for this problem:

.|...|..|..

• In this case if $n=8$ is the number of urns/bars and $k=4$ is the number of balls/stars then you want to use ${n+k-1 \choose k}$ or ${n+k-1 \choose n-1}$. But if $n=4$ is the number of balls/stars and $k=8$ is the number of urns/bars then you want to use ${n+k-1 \choose k-1}$ or ${n+k-1 \choose n}$ Commented Nov 4, 2020 at 1:12

First of all, when considering which of the numbers in the set $$\{1, 2, \cdots 999999999\}$$ have sum of digits equal to 13, you can pretend that the smaller numbers will be zero filled on the left, since including left-side zero digits does not affect the sum of the digits.

Second of all, it is impossible to have more than one specific digit equal to 9, and still have the sum of the digits equal to 13. Therefore, you can assume WLOG, that the leftmost digit is 9, obtain a computation, and then multiply this computation by 9 to get the final answer. The reason that you are applying the factor of 9 is that the 9-digit can occur in any of the 9 slots.

Using Stars and Bars analysis, as discussed here you want the number of non-negative solutions to

$$x_1 + x_2 + \cdots + x_8 = 4.$$

This computation is

$$\binom{4 + [8-1]}{8-1}.$$

$$9 \times \binom{4 + [8-1]}{8-1} ~=~ 2970.$$