How many whole numbers between $100$ and $800$ contain the digit $2$? I had a very strange doubt in this question while I was solving it. Now in order to solve first I calculated the three digit numbers which won't have $2$ at all in them and the number of such three digit numbers between $100$ and $800$ will be $=6 \times 9 \times 9 = 486$.
Now as per the question we do no have to include $100$ and $800$ while counting so the total number of numbers between $100$ and $800$ will be $699$ and hence the number of whole numbers which will have $2$ in it should be $699 - 486=213$.
But let's say you have included $100$ and $800$ too then this will give the total number of numbers between $100$ and $800$ (both inclusive) will be 701 and hence the number of whole numbers which will have $2$ in it should be $701- 486=215$.
And when you include only $100$ or $800$ any one of them then the total number of numbers between $100$ and $800$ (any one of them is inclusive) will be 700 and hence the number of whole numbers which will have $2$ in it should be $700- 486=214$.
Now I am getting confused as to which one of them is the correct answer. Am I doing any silly mistake here? Please help me on this !!!
Thanks in advance !!!
 A: When you count the number of three digit numbers that won't have a 2 in it, you're implicitly including 100, but not 800.
The way you count them (if I understand correctly), is that you have 6 choices for the first digit (1, 3, 4, 5, 6, 7), and then 9 choices for the second and third digit (1, 3, 4, 5, 6, 7, 8, 9, 0). So the two number 100 is a possibility here, but not 800.
So to get the right number in the end, you will have to include 100 but exclude 800.
Does that help?
A: The method you used to get $214$ is correct.
Why the method giving $213$ is wrong: It should be $699-485$
Can you find now the mistake in the step you are getting $215$?
A: Your $6\cdot 9\cdot9$ is saying {1,3,4,5,6,7} choices for first position and {0,1,3,4,5,6,7,8,9} choices for position 2 and 3. This means 100 is part of your 486.
I think you can figure it out from here!
A: For more advanced technique , use exponential generating functions.
Lets first fird the number of $3$ digits integers that contain at least one $2$. To find it write the exponential generating function form such that $$\bigg(x + \frac{x}{1}+\frac{x^2}{2!}\bigg)\bigg(1+x + \frac{x}{1}+\frac{x^2}{2!}\bigg)^9$$ where the former represent the exponential generating function form of $2's$ , the latter is for the numbers from $\{0,1,3,4,5,6,7,8,9\}$ .Now , find the coefficient of $x^3$ in the expansion and multiply it by $3!$.
https://www.wolframalpha.com/input/?i=expanded+form+of+%28x+%2B+x%5E2+%2F+2+%2Bx%5E3+%2F6%29+%281+%2B+x+%2Bx%5E2+%2F2+%29%5E9
Hence, $\frac{271}{6} \times 3! =271$
However, this solution contains some unwanted numbers such as $022,082,823,972,..$ etc. Hence , we must subtract them from $271$. To do that,

*

*Find three digits numbers that start with zero and contain at least one $2$. It is equal to the number of two digits numbers that contain at least one $2$.By using the coefficient in given link $\frac{19}{2} \times 2! =19$


*Find three digits numbers that start with $8$ and contain at least one $2$. It is equal to the number of two digits numbers that contain at least one $2$.By using the coefficient in given link $\frac{19}{2} \times 2! =19$


*Find three digits numbers that start with $9$ and contain at least one $2$. It is equal to the number of two digits numbers that contain at least one $2$.By using the coefficient in given link $\frac{19}{2} \times 2! =19$
$$\therefore 271 - (3 \times 19) = 271-57=214$$
Yes, you found the right !!
A: You can resolve your uncertainty by deriving the answer by an independent path. Every century has $10$ members with $2$ in the ones place plus $9$ more members with $2$ in the tens place (and not also in the ones place; avoid double counting), for a total of $19$. If we ignore the century with $2$ in the hundreds place, there are $6$ other centuries, and $6\times 19=114$. Add to that the $100$ numbers in the century with $2$ in the hundreds place, and you get $214$. So you know that whatever other reasoning path you take, the answer must be $214$, and if it isn't, you have to reevaluate your reasoning.
