JEE Main 2024 — 9 April, Evening Shift. Previous Year Question.
Problem
The number of integers between $100$ and $1000$ having the sum of their digits equal to $14$ is ____.
Key insight. A 3-digit number has three digits, each within its own range — the hundreds digit can’t be $0$, but the other two can. Counting solutions to $a+b+c=14$ without those range limits overcounts; the fix is inclusion-exclusion, subtracting off exactly the cases where a digit is pushed past $9$.
Watch this explained step by step → · More on the Shiwam’s Classes channel
Approach
Let the number be $\overline{abc}$ with $a \in \{1,\dots,9\}$ and $b,c \in \{0,\dots,9\}$, and $a+b+c=14$. Shift $a$ so every variable starts from $0$, count all non-negative integer solutions using stars-and-bars, then subtract off the solutions where any one digit exceeds $9$ using inclusion-exclusion.
Solution
Step 1 — Set up the equation and shift the hundreds digit
Let $a’=a-1$, so $a’ \in \{0,\dots,8\}$. The equation $a+b+c=14$ becomes:
$$a’+b+c = 13, \qquad 0 \le a’ \le 8,\ 0 \le b,c \le 9$$
Step 2 — Count all non-negative solutions, ignoring upper bounds
By stars-and-bars, the number of non-negative integer solutions to $a’+b+c=13$ is:
$$\binom{13+2}{2} = \binom{15}{2} = 105$$
Step 3 — Subtract the cases where a variable exceeds its bound
$a’ \geq 9$: substitute $a”=a’-9$, giving $a”+b+c=4$, with $\dbinom{4+2}{2}=\dbinom{6}{2}=15$ solutions.
$b \geq 10$: substitute $b’=b-10$, giving $a’+b’+c=3$, with $\dbinom{3+2}{2}=\dbinom{5}{2}=10$ solutions.
$c \geq 10$: by symmetry with $b$, also $10$ solutions.
Step 4 — Check for double-counted overlaps
Could two variables exceed their bounds simultaneously? For instance, $a’ \geq 9$ and $b \geq 10$ together would need $a”+b’+c = 13-9-10 = -6$, which is impossible. Every other pairwise overlap is similarly impossible, since two excesses together already exceed $13$. So nothing needs to be added back.
Step 5 — Apply inclusion-exclusion
$$\text{Valid solutions} = 105 – 15 – 10 – 10 = 70$$
Answer
$$70$$
Common mistakes
- Forgetting that $a$ (the hundreds digit) starts from $1$, not $0$. Treating all three digits as ranging over $0$–$9$ without the shift changes the equation’s constant and throws off every subsequent count.
- Skipping the overlap check in inclusion-exclusion. Even when the overlap turns out to be zero, verifying that two excess conditions can’t hold simultaneously is what makes the subtraction step valid rather than a lucky guess.
Practise next
- Find the number of integers between $1000$ and $10000$ whose digits sum to $20$, using the same shifted stars-and-bars approach with a fourth digit.
Show answer
$597$. Write the number as $d_1d_2d_3d_4$ with $1\le d_1\le9$ and $0\le d_2,d_3,d_4\le9$. Substituting $d_1=e_1+1$ shifts the problem to $e_1+d_2+d_3+d_4=19$ with all four in $[0,8]$ or $[0,9]$.
Ignoring the upper caps, stars and bars gives $\binom{22}{3}=1540$. Subtracting the cases where one variable exceeds its cap, then adding back the double over-counts by inclusion–exclusion, leaves $597$.
Direct enumeration of the $9000$ four-digit numbers confirms $597$ — worth doing once, because the inclusion–exclusion bookkeeping is where this goes wrong.

Doubts are answered by Shiwam, usually within a day. Ask about this question specifically — a general question about the chapter is better asked in class.