$f (x) = 1$ if the digit $9$ appears in the decimal representation of $x$ and $f (x) = 0$ otherwise — show that $f$ is continuous 
The function $f : [0, 1] \to \Bbb R$, where $f (x) = 1$ if the digit $9$ appears in the decimal representation of $x$ and $f (x) = 0$ otherwise. We use a decimal representation that does not end in repeating $9$s.  Show that $f$ is continuous at $x$ if and only if $f (x) = 1$.  (Use only $\varepsilon$, $\delta$ definition of continues. You are not allowed use limit).


I intuitively know that if $x$ is a decimal which appears $9$ then we can find another decimal in any neighbourhood with the same property. if not then again we can find another decimal in any neighbourhood which appears $9$. But how write it formally I couldn't. After several days I gave up. Actually I understand the basic idea. But I couldn't write formally anything. Please help me.
 A: The set of numbers with a $9$ in the decimal representation is dense in $[0, 1]$ (just replace the $n$-th digit by $9,$ for some high $n.$) This shows that the function is not continuous if it is $0.$ On the other hand, the set of numbers which do not have a nine is not dense (a number which has a nine in the $k$-th position will have it if perturbed by something smaller than $10^{-k-2}.$)
A: A more elementary approach,
First of all let $f(x)= 0$ then i.e. $x = \sum_{i=1}^{\infty} \frac{x_i}{10^i}$ where $x_{i}\neq 9$, $\forall \ i$. Then for every $\epsilon >0 $, there exists large enough $i_0$ such that, $y := \sum_{i=1}^{i_0 - 1} \frac{x_i}{10^i} + \frac{9}{10^{i_0}} + \sum_{i=i_0}^{\infty} \frac{x_i}{10^i}$, is $\epsilon$-close to $x$, but $f(y)=1$. So indeed $f$ is not continuous at $x$ where $f(x)=0$.
Now let $f(x)=1$. Then $9$ appears in its decimal representation and consider $i_1\geq 1$ such that $9$ appears for the first time in its decimal expansion i.e.  $x = \sum_{i=1}^{i_1 - 1} \frac{x_i}{10^i} + \frac{9}{10^{i_1}} + \sum_{i=i_1}^{\infty} \frac{x_i}{10^i}$, where $x_i\neq 9$ for all $1\leq i < i_1$. Then for $\epsilon_1 < \frac{9}{10^{i_1 +1}}$ we have that every $y$ that is $\epsilon_1$-near $x$ has $9$ in its decimal expansion and more precisely $y_i = x_i$ for (at least) all $1\leq i \leq i_1$
