Sum of Integers Without Digits 7 or 8
What is the sum of all integers from 1 to 100 that do not contain the digit 7 or the digit 8?
For example, 17, 72, and 88 would be excluded, while 23, 59, and 100 would be included.
Hints
- Use complement counting: total sum of 1 to 100 is $5050$. Subtract the sum of numbers that contain a 7 or 8.
- Carefully enumerate numbers with digit 7 or 8. Split into: ones digit is 7, ones digit is 8, tens digit is 7 (new), tens digit is 8 (new). Watch for double-counting numbers like 77, 78, 87, 88.
- There are 36 excluded numbers. Sum them group by group: ones-digit-7 gives 520, ones-digit-8 gives 530, tens-digit-7 (remaining) gives 590, tens-digit-8 (remaining) gives 670. Total excluded: 2310.
Worked Solution
How to Think About It: The direct approach -- enumerate all numbers containing 7 or 8 and subtract from the total -- works fine here because the range is small. The cleaner approach is complement counting: total sum minus the sum of numbers that contain at least one 7 or 8. Alternatively, you can build the valid numbers digit by digit, but for 1-100 that's overkill.
Quick Estimate: Out of 100 numbers, how many contain a 7 or 8? In each decade (e.g., 1-10, 11-20), exactly 2 numbers have a 7 or 8 in the ones place (like 7, 8, 17, 18, ...). That gives 20 numbers. But the 70s and 80s contribute an additional 16 numbers (70-79 and 80-89, minus the 4 already counted: 77, 78, 87, 88). So roughly 36 numbers are excluded. Their average might be around 60, so excluded sum is about $36 \times 60 \approx 2160$. Answer is roughly $5050 - 2160 \approx 2890$.
Approach: Complement method -- compute total sum and subtract the sum of excluded numbers.
Formal Solution:
Total sum: $\sum_{k=1}^{100} k = \frac{100 \times 101}{2} = 5050$.
Note: 100 has digits 1, 0, 0 -- no 7 or 8, so 100 is included. We only need to check 1-99.
Numbers from 1 to 99 that contain digit 7 or 8:
- Ones digit is 7: $7, 17, 27, 37, 47, 57, 67, 77, 87, 97$ (10 numbers)
- Ones digit is 8: $8, 18, 28, 38, 48, 58, 68, 78, 88, 98$ (10 numbers)
- Tens digit is 7 (not already counted): $70, 71, 72, 73, 74, 75, 76, 79$ (8 numbers; 77 already counted)
- Tens digit is 8 (not already counted): $80, 81, 82, 83, 84, 85, 86, 89$ (8 numbers; 87, 88 already counted)
Total excluded: $10 + 10 + 8 + 8 = 36$ numbers.
Sum of excluded numbers:
- Ones digit 7: $7 + 17 + 27 + 37 + 47 + 57 + 67 + 77 + 87 + 97 = 520$
- Ones digit 8: $8 + 18 + 28 + 38 + 48 + 58 + 68 + 78 + 88 + 98 = 530$
- Tens digit 7 (remaining): $70 + 71 + 72 + 73 + 74 + 75 + 76 + 79 = 590$
- Tens digit 8 (remaining): $80 + 81 + 82 + 83 + 84 + 85 + 86 + 89 = 670$
Total excluded sum: $520 + 530 + 590 + 670 = 2310$.
$$\text{Answer} = 5050 - 2310 = 2740$$
Answer: The sum of all integers from 1 to 100 that contain no digit 7 or 8 is $\boxed{2740}$.
Intuition
This is a classic mental math / careful enumeration problem that tests your ability to organize cases and avoid double-counting. The complement approach (total minus bad) is almost always cleaner than direct enumeration for "sum of numbers satisfying a digit constraint" problems. The key pitfall is double-counting: numbers like 77, 78, 87, 88 have both a bad tens digit and a bad ones digit, so if you enumerate by digit position, you must use inclusion-exclusion or be careful to list each number exactly once. In interviews, the most common error is rushing through the enumeration and getting the count or sum wrong -- slow down and group systematically.