Calculate number of elements in a set How many natural numbers are there below 1000 that are multiples of 3 or that contain 3 in any digit of the number?
My effort : Here we need to calculate union of two set. First set is natural number which are multiple of 3. So it's cardinality will be the nearest integer of 1000/3, which will be 333. But I am confused with second set.
Any help/hint in this regards would be highly appreciated. Thanks in advance!
 A: The cardinality of the second set can be calculated as the complement of those numbers not containing $3$, thus (since we can choose each digit independently for $10^3=1000$ possibilities) $10^3-9^3=271$.
Those numbers in the intersection of the two sets, those divisible by $3$ and containing it as a digit, may be calculated as the sum of the following disjoint cases:


*

*One $3$. The $3$ may be placed in any one of $3$ positions, and the other two digits must form a number divisible by $3$. There are $33$ such two-digit numbers, but we exclude $03,30,33,36,39,63,93$ for including a $3$ themselves. Hence there are $3×(33-7)=78$ numbers in this case.

*Two $3$s. Again, the $3$'s may be placed in $3$ configurations. The remaining digit must be $0,6,9$, so there are $3×3=9$ numbers in this case.

*The only admissible number with three threes is of course $333$.


Thus the intersection contains $78+9+1=88$ numbers. The desired answer is then $333+271-88=516$.
A: How many numbers have $3$ as a first digit?  How many number that do not have $3$ as a first digit have $3$ as a second?  How many that do not have $3$ in one of the first two positions have $3$ in the third?  Add these together to answer your question.  You can't just add this to $333$ because all the ones that are multiples of $3$ and have a $3$ in them have been counted twice.
A: Well, inclussion exclusion says the answer will be
(A)#numbers divisible by three + (B)#numbers with at least one three - (C)#numbers divisible by three and at least on three.
(A) is easy.  $\lfloor \frac{1000}3 \rfloor = 333$.
(B) = #total number - #numbers with not threes.
If we consider the numbers as three digits from $000$ to $999$ there are $10^3$ where the digits can be anything and $9^3$ where the digits can be anything but $3$.  So $B=  10^3 -9^3 = (10-9)(10^2 + 10*9 + 9^2)= 271$
(C) is the tricky one but if you know the "rule of three" that if $100a + 10b + c$ is a multiple of $3$ then $a+b+c$ is a multiple of $3$.  And if one of $a,b,c$ is $3$ then the other two add to a multiple of $3$.
Those options are $0+3, 1+2, 2+1,3+0, 0+6, 1+5$ etc.  but we have to worry of double counting.
(C) = (D)#with exactly one three and the other two adding to a multiple of three + (E)#with exactly two threes and the third being a muliptle of three + (F)#with exactly three threes.
For (D) the other two numbers can be $(1,2),(2,1),(1,5),(2,4),(4,2),(5,1),(1,8),(2,7),(4,5),(5,4),(7,2),(8,1)$.  That is $12$ options.  ANd there are three options for which digit is the $3$.  So $D = 3*12=36$
For (E) the third digit can be $0,6$ or $9$.  And there are $3$ positions it can be in.  So (E) = $3*3=9$.
And (F) is obviously equal to $1$.
So $C = 36+9 + 1 = 46$.
We have A + B -C= $333 + 271- 46 =558$.
