The digit 9 appears 20 times when writing all integers from 1 to 100 inclusive.
Here's how to count them:
- Numbers with 9 in the units place:
These are 9, 19, 29, 39, 49, 59, 69, 79, 89, 99. (10 occurrences)
- Numbers with 9 in the tens place:
These are 90, 91, 92, 93, 94, 95, 96, 97, 98, 99. (10 occurrences)
When we sum these, the number 99 contributes two 9s (one from the units place list and one from the tens place list), so it is correctly counted twice.
Total occurrences = 10 (from units place) + 10 (from tens place) = 20.