How many 5 digits numbers are there, whose digits sum to 22? Of course the first digit has to be larger than 0.
[Math] How many 5 digits numbers are there, whose digits sum to 22
combinatorics
Related Question
- [Math] How many natural numbers less than $10^8$ are there, whose sum of digits equals $7$
- [Math] How many 10 digit numbers are there so the sum of the digits is $2$
- [Math] How many odd three-digits numbers are there whose all three digits are different
- [Math] How many $6$ digit numbers are there whose digits sum to $51$
- How many $3$-digit numbers are there whose sum of digit is $10$
- How many 5-digit numbers such that the sum of their digits is a multiple of 4
Best Answer
The objects you are counting may be placed into bijection with solutions to $$x_1+x_2+x_3+x_4+x_5=22$$ such that $0\le x_i\le 9$ and also $x_1\ge 1$. Via the substitution $x_1'=x_1-1$, we may instead solve $$x_1'+x_2+x_3+x_4+x_5=21$$ such that the variables are nonnegative integers, and also $x_1\le 8, x_i\le 9$ ($2\le i\le 5$).
Without the upper bound restriction, using stars and bars, there are ${26 \choose 22}$ solutions. Now we must consider the various upper bounds, using inclusion-exclusion. Let $A_1$ denote the set of solutions where $x_1'>8$, and $A_i$ denote the set of solutions where $x_i\ge 10$. By considering the substitution $x_1''=x_1-9\ge 0$, we have $$x_1''+x_2+x_3+x_4+x_5=12$$ Again using the stars-and-bars approach, we have $|A_1|={17\choose 13}$. If instead we want $x_2\ge 10$, we use the substitution $x_2'=x_2-10\ge 0$ and $$x_1'+x_2'+x_3+x_4+x_5=11$$ and so $|A_2|={16\choose 12}$. By symmetry, $|A_3|=|A_4|=|A_5|$.
To complete the problem, you also need to compute all the various $|A_1\cap A_2|$ and $|A_2\cap A_3|$, and then combine all the data using the inclusion-exclusion principle, which I leave for you as an exercise.