# How many times does $3$ appear in the $\{3,6,9,\ldots,1002\}$?

A set $S$ is defined as $S = \{3,6,9,\ldots,1002\}.$
How many times does digit three appear in the decimal representations of members of $S$?

I have solved this question by seeing pattern like $3, 6, 9$, but is there a general solution?

-
by general solution, you mean for like any digit? for any range for the set? – mathguy Aug 18 '12 at 16:22
yes for any digit – Arpit Bajpai Aug 19 '12 at 3:54

Hint: how many numbers are in the set? How many 3's appear in the units place? In the tens place?

-

We should count all 3 digits. We will suggest that all numbers in your set have 3 digits: (003, 006,009, 999). "3" appears in the last position every 10 times, starting from the first number of set. (Because of cycle (3,6,9,2,5,8,1,4,7,0,3)). So we have 34 "3" in the last position. And it is very clear that in the first position "3" appears 34 times. If "a" is on the first position and a+3=3m+r: if r=0 then "3" appears on the second position 4 times and 3 times in other cases. This give us, that when "0,3,6,9" in the first position, we have "3" 4 times on the second position and 3 times in other cases. It give us 4·4+6·3=34 "3" on the second place. So we have total 34+34+34=102 digits "3" in your set.

May be there are more simple solution.

ps. For the Set $\{3,6,..., 10^n-1 \}$ on each place we have $[\frac{10^n}{3}]+1$ digits "3". So we have total $n \cdot \left([\frac{10^n}{3}] +1) \right)$ digits "3".

-