Many problems are too tangled to attack all at once, but fall apart when you split them into cases. The skill is choosing the split: the cases must not overlap, and together they must cover everything.
Good splits usually come from the most restricted part of the problem: the first digit of a number, the person with the most conditions, the largest object, or the remainder on dividing by a small number.
When to try it
The problem has a condition that behaves differently in different situations (a digit can be 0 except at the front; an angle could be the odd one out or one of a pair).
A count would be easy if one thing were fixed: fix it, count, then add over its possible values.
You keep finding answers but cannot tell whether you have them all.
Watch out: Check that the cases do not overlap (or you count some things twice) and that none is missing. A quick total check (all cases should add up to an easy overall count) catches most mistakes.
Two worked examples
Try each one first. The hints and the full solution are underneath.
Problem J01
Junior · Number theoryShort answerSolved
How many whole numbers from 1 to 200 have digits that add up to 5?
Hint
Sort them by how many digits they have: one digit, two digits, then three digits starting with 1.
Second hint
One digit: just 5. Two digits: the tens digit is 1 to 5. Three digits from 100 to 199: the last two digits add to 4.
Full worked solution
Answer: 11
Split the numbers 1 to 200 by how many digits they have; the cases cannot overlap.
One digit: only 5 has digit sum 5. That is 1 number.
Two digits 10a + b with a ≥ 1 and a + b = 5: a can be 1, 2, 3, 4 or 5, giving 14, 23, 32, 41, 50. That is 5 numbers.
Three digits from 100 to 199: the first digit is 1, so the last two digits must add to 4: 104, 113, 122, 131, 140. That is 5 numbers.
200 has digit sum 2, so it does not count.
Total: 1 + 5 + 5 = 11.
Why this works: Splitting a count into cases that cannot overlap (here, by number of digits) turns one messy count into several small, easy ones.
Where it leads: Counting numbers with a given digit sum is a ‘stars and bars’ problem in disguise; the restriction that digits are at most 9 is what makes larger cases interesting.
For how many whole numbers n from 1 to 1000 does n2 end in the digits 21?
Hint
The last two digits of n2 depend only on the last two digits of n. Which last digits can n have?
Second hint
n must end in 1 or 9. Writing n = 10a + 1, n2 ≡ 20a + 1 (mod 100): when is that 21?
Full worked solution
Answer: 40
The last two digits of n2 depend only on the last two digits of n, so work with n = 10a + b, where b is the units digit and a the tens digit.
n2 ends in 1, so b2 ends in 1: b = 1 or b = 9.
b = 1: n2 = 100a2 + 20a + 1. Its tens digit is the units digit of 2a, which must be 2, so a ends in 1 or 6: n ends in 11 or 61.
b = 9: n2 = 100a2 + 180a + 81. Its tens digit is the units digit of 18a + 8, i.e. of 8a + 8, which must be 2, so 8a ends in 4: a ends in 3 or 8: n ends in 39 or 89.
So 4 numbers in every block of 100, and 1 to 1000 is 10 blocks: 4 × 10 = 40.
Why this works: Working modulo 100 means you only ever look at the last two digits. Expanding (10a + b)2 shows exactly which digit of n controls which digit of n2.
Where it leads: Solving n2 ≡ c modulo powers of 10 digit by digit is Hensel lifting, a key tool in number theory.