we are to count how many times the digit 7 appears when listing integers from 1 to 1000 inclusive
this includes 1 to 999 plus 1000
we’ll count how many times 7 appears in each digit place across numbers 000 to 999
we treat numbers as 3-digit numbers with leading zeros to make counting easier
positions: hundreds, tens, units
loop over all numbers from 000 to 999
count how many times 7 appears in each digit position independently
total numbers = 1000 (000 to 999)
hundreds place:
for 7 to appear in the hundreds place, the number must be 7xx
there are 10 choices for tens (0 to 9) and 10 choices for units
10 × 10 = 100 numbers with 7 in the hundreds place
tens place:
for 7 to appear in the tens place, number must be x7x
10 choices for hundreds, 10 for units
10 × 10 = 100 numbers with 7 in the tens place
units place:
number must be xx7
10 choices for hundreds, 10 for tens
10 × 10 = 100 numbers with 7 in the units place
so total from 000 to 999 = 100 + 100 + 100 = 300
now include 1000
digit 7 does not appear in 1000
so total stays 300
final answer is d
Now, there was a doubt that I had while using this approach "but aren't we double counting here?" what i thought was some no.s will be repeated here..like 777 etc. now, let’s clear this up step by step.
you’re right to wonder if we’re double-counting, but the approach avoids that by counting digit positions independently — not entire numbers.
here’s what’s happening:
we are not counting how many numbers contain a 7
we are counting how many times the digit 7 appears in any digit position across all numbers from 1 to 1000
so
repetition across numbers is expected and allowed
example: number 777 has three 7s
it will be counted once in hundreds, once in tens, once in units
that’s perfectly correct for this problem, because we’re being asked how many times the digit 7 appears, not how many numbers contain it
so for numbers 000 to 999:
– 100 have 7 in the hundreds place
– 100 have 7 in the tens place
– 100 have 7 in the units place
so 300 total appearances of the digit 7
number 1000 has no 7
so the total remains 300
there’s no overcounting because we’re not trying to count unique numbers with 7 — we’re counting total appearances of 7
final answer: 300
and no double-counting issue here