0
$\begingroup$

I'm sorry I have asked until now up to three questions regarding the same topic, but tomorrow I have a Combinatorics exam and I'm practising in order to be ready and do my best. Here is the question: I am requiered to find how many numbers in the set $\{1\dots 1000\}$ there are whose sum of digits is $5$. Here is my attempt:
I started separating in cases, depending on how many digits there were:

  1. If we only have one digit, it is easy: only the number $5$ satisfies it: 1 option
  2. If we have two digits, it is the same as solving $x_1 + x_2 = 5$, where $x_i$ is the $i$-digit and $x_1 \geq 1, x_2 \geq 0$. The number of solutions is, if I'm not wrong, ${5 \choose 1} = 5$
  3. If we have three digits, the argument is the same as above, but with three variables: $x_1 + x_2 + x_3 = 5, x_1 \geq 1, x_2,x_3 \geq 0$. The number of solutions is ${6 \choose 2} = 15$. Therefore, and since cases are mutually exclusive, the result would be the sum of these three options: $21$. Am I right?
$\endgroup$
2
  • 3
    $\begingroup$ Looks good. $\quad $ $\endgroup$
    – lulu
    Commented Oct 23, 2023 at 19:09
  • 2
    $\begingroup$ As a mechanical check, the direct count is pretty easy. The only challenge is for the three digit numbers, but you only need to look at the numbers in $\{104, 113, \cdots, 500\}$ and that's not that bad. $\endgroup$
    – lulu
    Commented Oct 23, 2023 at 19:12

1 Answer 1

4
$\begingroup$

Your argument works, but there's a more elegant solution!

Allow leading zeroes. Ignoring the number $1000$, whose digits don't sum to $5$ anyway, treat each number as a $3$-digit string $d_2d_1d_0$. So we're looking to enumerate integer solutions to $$ d_0 + d_1 + d_2 = 5, $$ where each $d_i \geq 0$. This is a stars-and-bars calculation: $$ \binom{5+3-1}{3-1} = \binom{7}{2} = 21. $$

$\endgroup$
1
  • $\begingroup$ I still cannot understand how I couldn't come up directly with that. Thanks for your answer $\endgroup$
    – Emmy N.
    Commented Oct 23, 2023 at 19:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .