How many integers from $1$ through $999,999$ contains digit $1$? How many integers from $1$ through $999,999$ contains digit $1$?
I have no idea to solve this problem. Have anyone give me some advice?
Thanks in advance!!
 A: HINT: Consider those integers as six character strings over the alphabet $\{0,1,2,3,4,5,6,7,8,9\}$. How many strings don't contain $1$? It might be helpful to add $0$ to your range of integers first.
A: How many numbers don't contain a 1?
First lets extend our range: $0 = 000000$ to $999999$
From this We can work out the probability that the number does not contain a 1
$$\left(\frac{9}{10} \right)^{6}$$
And the total number
$$10^6 \times \left(\frac{9}{10} \right)^{6} = 531441$$
Now we have over counted by 1 because we extended the range so there are $531440$ numbers that don't contain any 1 so there must be $999999 - 531440 = 468559$ that do contain at least one 1.
A: While Asaf's answer is the simplest, we can also use the Inclusion-Exclusion Principle to answer this question.
Let $A_i$ be the set of numbers with a '$1$' in digit $i$. The sum of the intersection of $k$ of the $A_i$'s is
$$
10^{6-k}\binom{6}{k}
$$
That is for each of the $\binom{6}{k}$ choices of the $A_i$'s, there are $10^6-k$ numbers with a '$1$' in the specified digit. The Inclusion-Exclusion Principle says that the count of numbers containing a $1$ is
$$
\sum_{k=1}^6(-1)^{k-1}10^{6-k}\binom{6}{k}
$$
which is
$$
\begin{align}
&10^5\binom{6}{1}-10^4\binom{6}{2}+10^3\binom{6}{3}-10^2\binom{6}{4}+10^1\binom{6}{5}-10^0\binom{6}{6}\\
&=600000-150000+20000-1500+60-1\\[8pt]
&=468559
\end{align}
$$
