Show that the function $f$ is continuous only at the irrational points 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.
 A: Firstly, $f$ can't be continuous at any rational point. Because if $x =\frac{m}{n}$ with $(m,n) = 1$, then $f(x) = \frac{1}{n}$. But we can always find an irrational sequence $x_n \to x$ and $f(x_n) = 0$ doesn't converge to $\frac{1}{n}$. 
Secondly, $f$ is continuous at irrational points. 
Take any $y$ irrational so $f(y) = 0$. For any $\epsilon >0$, we know the number of intgers $n$ such that $\frac{1}{n} > \epsilon$ is finite. For each fixed such $n$, the number of $m$ such that $\frac{m}{n}$ is in the interval $[y-1, y+1]$ is finite. Thus the number of rational numbers $\frac{m}{n}$ in the interval $[y-1, y+1]$ with $\frac{1}{n} > \epsilon$ is finite. Define $d$ as the smallest distance of these $\frac{m}{n}$ with $y$. Then for any $z$ with $|y-z|<d$ we have $|f(z)-f(y)|<\epsilon$
A: Yes you have proceeded in a right way. 
Observe for any $\epsilon>0$ $\exists n\in \Bbb N$ s.t $\frac1n<\epsilon$ & for any $a\in \Bbb R\setminus \Bbb Q$ we can choose $\frac pq \in \Bbb Q$ s.t $\frac 1q<\frac1n<\epsilon$
