There are several ways to answer this. I think this is the easiest:
Count the number of three-digit numbers:
The first digit can be 1-9; the second and third digits can be 0-9. So, there are 9 choices for the first digit and 10 choices for the second and third digits. This gives you
9 x 10 x 10 = 900 three-digit numbers. Right?
Then count the number of three-digit numbers that do NOT contain the digit 2. This is done similarly! Try it!
Now, if you think about it, the difference between these two quantities IS the number of three-digit numbers that DO contain a 2, which is what you wanted.
874
17
There are 9000 4-digit numbers. 8*9*9*9 = 5832 of them do not contain a 5 The remaining 3168 contain a 5.
-2
-5
648
874
27: 077,177,277,377,477,577,677,877,977,717,727,737,747,757,767,777,787,797
17
There are 9000 4-digit numbers. 8*9*9*9 = 5832 of them do not contain a 5 The remaining 3168 contain a 5.
1
-2
-5
-5
It would help to know which digit. 0 appears in 9 numbers and each of the others in 18 numbers.
252
There are 6804 such numbers.