How many times will the digit '3' appear if we write all whole numbers from 1 to 9999?
1. The numbers in which 3 occurs only once. This means that 3 is one of the digits and the remaining two digits will be any of the other 9 digits
You have 1*9*9 = 81 such numbers. However, 3 could appear as the first or the second or the third digit. Therefore, there will be 3*81 = 243 numbers (1-digit, 2-digits and 3- digits) in which 3 will appear only once.
2. The numbers in which 3 will appear twice. In these numbers, one of the digits is not 3 and it can be any of the 9 digits.
There will be 9 such numbers. However, this digit which is not 3 can appear in the first or second or the third place. So there are 3 * 9 = 27 such numbers.
In each of these 27 numbers, the digit 3 is written twice. Therefore, 3 is written 54 times.
3. The number in which 3 appears thrice - 333 - 1 number. 3 is written thrice in it.
Therefore, the total number of times the digit 3 is written between 1 and 999 is 243 + 54 + 3 = 300