# Find the number of seven-digit positive integers such that the sum of the digits is 19

Find the number of seven-digit positive integers such that the sum of the digits is 19.

$$\binom{24}{6} - \binom{15}{6} - 6\binom{14}{6}$$

Denote the digits from left to right by $$x_1,... , x_7$$. Then the answer is the number of solutions of $$x_1 + ... + x_7 = 19$$ in non-negative integers not exceeding 9, but with the additional restriction that $$x_1$$ is positive.

This is the question and answer from the book "Math of Choice". My question is why did the author uses 25 instead of 24 since there are 7$$x$$, hence, shouldn't it be $$\binom{19+7-1}{7-1}$$?

Kindly advise

• You have to subtract $1$ to cope with the condition that $x_1>0$.
– lulu
May 23, 2022 at 22:34
• @lulu, thank you for the reply. If I were to subtract 1 to account for $x_1 > 0$, shouldn't i be subtracting 1 from 6 too? Which derives to $\binom{24}{5}$ May 23, 2022 at 22:45
• If we let $X_1=x_1-1$ the problem is now to count the solutions to $X_1+x_2+\cdots +x_7=18$ in non-negative integers. This is a routine Stars and Bars problem, and the usual formula applies.
– lulu
May 23, 2022 at 22:49

## 2 Answers

Not quite a routine stars and bars question.

The first digit has to be $$\geq 1$$, whereas the others can be $$\geq 0$$

We can equalize the lower limits by substituting $$X_1 = x_1-1$$ as suggested by @lulu to make the equation
$$X_1 +x_2 +...+x_7=18$$ in non-negative integers,

but then the upper limit for $$X_1$$ is $$8$$, while it is $$9$$ for the rest, and we need to take care of this idiosyncrasy while applying inclusion-exclusion,

that is why the answer will be $$\dbinom{24}{6} - \dbinom11\dbinom{24-9}{6} - \dbinom61\dbinom{24-10}{6}$$

= $$\dbinom{24}6- \dbinom{15}6 - 6\dbinom{14}6$$

I have a stupid question :

Can I replace $$\binom{1}{1}\binom{24-9}{6}$$ by $$\binom{18-9+5}{5}$$? (It means in case $$x_1=9$$). Thus:

$$\binom{24}{6}-\binom{14}{5}-6\binom{14}{6}$$