Prove that the function $f$ is continuous only at the irrational points.
$f(x)=\begin{cases} 0 & ;x \in \mathbb R-\mathbb Q \\ \dfrac{1}{n} & ;x=\dfrac {m}{n} :\gcd(m,n)=1;m,n \in \mathbb Z \\ 1 & ;x=0 \end{cases}$
Attempt: Let us suppose $a \in [0,1]$ such that $f$ is continuous in $[0,1]$ Then :
$\forall \epsilon >0, \exists \delta >0 $ such that $|g(x)-g(a)|< \epsilon$ whenever $|x-a|< \delta$
Case $1$ :Suppose $a$ is a rational element in the interval $[0,1]$
Then if $a=\dfrac {p}{q} \implies g(a) = \dfrac {1}{q}$. Hence :
$|g(x)-\dfrac {1}{q} |< \epsilon~~~........(1)$.
$(a)$ Now, if $x$ is a rational element, then $(1)$ reduces to $\dfrac {1}{q} < \epsilon$ which is not true always.
Hence, there is no continuity for any rational point $a$
Case $2$ :Suppose $a$ is an irrational element in the interval $[0,1]$
$\forall \epsilon >0, \exists \delta >0 $ such that $|g(x)-g(a)|< \epsilon$ whenever $|x-a|< \delta$
Hence, $|g(x)-0|< \epsilon ~~~...........(2)$
$(a)$ Now, if $x= \dfrac {r}{s}$ is a rational element: $g(x) =\dfrac {1}{s}$
There always exist an integer $s$ such that $(2)$ holds
But, how do we find the value of $\delta$?
$(b)$ If $x$ is an irrational element, then $|g(x)|=0< \epsilon$
Which is always true for any $\delta$.
Did I attempt this problem correctly?
Thank you for your help.