$n < 10$ be a non-negative integer. How many integers from $0$ to $999$ inclusive have the sum of their digits equal to $n$? Give your answer in terms of $n$. Hint: Try first for integers from $0$ to $99$.
-
- How many
$3$digit numbers, whose digits consist solely of even numbers, exist? - A ternary number consists of only
$2$s,$1$s and$0$s. How many values can be represented by a$7$digit ternary number?
- How many
-
You can use inspection (there are only 10 cases) for the case of max 2 digits to get an expression in terms of
$n$. -
For the case of max 3 digits, what if you fix one digit to some value
$p\le n$? -
What must be the sum of the remaining max 2 digits in terms of
$p$and$n$? -
How many max 2 digits numbers have their digit sum equal to
$n-p$? -
How should we incorporate that for all values of
$p$?
-
For max
$99$(max 2 digits) case one can observe, by inspection, that there are$n+1$numbers whose digit sum is$n$.When there are max 3 digits, let’s fix one of the digits to
$p\le n$. The sum of the remaining max 2 digits must thus equal$n-p,$and we know there are$n-p+1$numbers with that property. Taking all possible values of$p$we get$$\begin{aligned}\sum_{p=0}^n (n-p+1)&=(n+1)\sum_{p=0}^n 1-\sum_{p=0}^n p\\&=\frac{(n+1)(n+2)}{2}.\end{aligned}$$