For how many natural numbers smaller then one million the sum of their digits is:
- $5$?
- a maximum of $6$?
- $47$?
The answers:
- ${5+6-1\choose 6-1}$
- ${5+7-1 \choose 7-1}$
- ${7+6-1 \choose 6-1}$
Can you help with understanding why they are correct?
For how many natural numbers smaller then one million the sum of their digits is:
The answers:
Can you help with understanding why they are correct?
If a number is "smaller than one million", then we can write it using $6$ digits (perhaps with some leading zeroes). So $001310$ would be one such number, but we would typically write it $1310$. Fortunately, the presence of leading zeroes does not affect the sum of the digits.
From here, these answers come from a stars and bars argument. The digits sum to $5$, so we have $5$ stars, and we can place the stars into six bins: bin $i$ containing $d$ stars if the $i$-th digit is $d$. The boundary of the bins are represented using bars. So the number $001310$ would correspond to $$\overbrace{ \phantom{\star}}^{0}|\overbrace{ \phantom{\star}}^{0}|\overbrace{\star}^1|\overbrace{\star\star\star}^3|\overbrace{\star}^1|\overbrace{ \phantom{\star}}^{0} \qquad\leftrightarrow\qquad 1310.$$ Other examples are: $$\overbrace{\star}^{1}|\overbrace{ \phantom{\star}}^{0}|\overbrace{\star}^1|\overbrace{\star}^1|\overbrace{\star}^1|\overbrace{\star}^1 \qquad\leftrightarrow\qquad 101111$$ and $$\overbrace{ \phantom{\star}}^{0}|\overbrace{ \phantom{\star}}^{0}|\overbrace{ \phantom{\star}}^{0}|\overbrace{ \phantom{\star}}^{0}|\overbrace{ \phantom{\star}}^{0}|\overbrace{\star\star\star\star\star}^{5} \qquad\leftrightarrow\qquad 5$$
There are $5$ stars and $6-1=5$ bars, so we choose to position of the the $6-1$ bars, thus giving $\binom{5+6-1}{6-1}$.
if we have the sum of digits being "a maximum of 6", we can introduce a "rubbish bin": stars in this bin are ignored. For example $$\underbrace{\overbrace{\star\star}^2}_{\text{ignore}}|\overbrace{ \phantom{\star}}^{0}|\overbrace{ \phantom{\star}}^{0}|\overbrace{\star}^1|\overbrace{\star}^1|\overbrace{\star}^1|\overbrace{ \phantom{\star}}^{0} \qquad\leftrightarrow\qquad 1110.$$
The method is the same as in part 1., except instead of bin $i$ having $d$ stars implying the $i$-th digit is $d$, it implies the $i$-th digit is $9-d$. We have $6 \times 9=54$ is the maximum digit sum, and we subtract a total of $7$ from these digits to get a digit sum of $47$.