Problem 8 · Count digit occurrences by position · 5 points
Made by AI and not reviewed by a real person.
Ola writes every number from 1 to 9999. In the numbers whose digits add up to 14, how many times does she write the digit 7?

- 112
- 36
- 140
- 138
- 144
Show a hint
- Count written 7s, not just numbers: one number might contribute twice. You can imagine zeros in front of shorter numbers.
- Choose a place for one 7. Count the ways the other three digits can add up to what is needed by considering their first digit in turn.
Show the answer and solution
Answer: E — 144
Imagine every number written with four digits, adding zeros in front if needed. Choose the place of a written 7; the other three digits must add up to 7. If the first of those digits is 0, there are 8 ways to choose the final two; if it is 1, there are 7 ways; and so on down to 1 way. That makes 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 = 36 for each of the four places, or 144 written 7s. The tempting answer 138 counts numbers instead: six numbers have two 7s and must each contribute twice.