Where is my logic wrong? I want to count how many numbers with the digit $2$ there are between $100$ and $400$. I thought the following: I will separate in cases.
First case. The first digit is one, the second is two, and the third is anyone. So I have $1*1*10=10$. For the second case, the first number is still one, the second is anything but two, as I already used it in the first case and the last one is two. So it will be $1*9*1=9$.
For the third case, the first digit is two and the last two, any one. So it will be: $1*10*10=100$. For the next case, the first number is three, the second is two and the third is anything, so we have: $1*1*10=10$.
For the final case, we have: the first number is three, the second is anything but two, and the third is two: $1*9*1=9$. Adding up, you have $138$. Where did I go wrong? I know it's not difficult to analyze the amount of numbers with the digit two in another way. But I would like to solve this using the fundamental counting principle.
Let $A_1$ be the set of numbers with a $2$ in the first digit.
Let $A_2$ be the set of numbers with a $2$ in the second digit.
Let $A_3$ be the set of numbers with a $2$ in the third digit.
The Inclusion-Exclusion Principle says that the count of numbers with a $2$ is $$ \overset{100\\}{|A_1|}+\overset{30\\}{|A_2|}+\overset{30\\}{|A_3|}-\overset{10\\}{|A_1\cap A_2|}-\overset{10\\}{|A_1\cap A_3|}-\overset{3\\}{|A_2\cap A_3|}+\overset{1\\}{|A_1\cap A_2\cap A_3|}=138 $$ So, your answer seems correct.