Let $ f(x) = \left\{ \begin{array}{lr} \frac{x}{3} & x ~\textrm{is rational},\\ x & x ~\textrm{is irrational}. \end{array} \right. $
Show that $f$ is continuous at $a \in \mathbb{R}$ if and only if $a=0$.
My initial approach is to use the sequential criterion with the use of density of rational numbers but I wasn't successful. Any help is much appreciated.
Let $x \in \mathbb R$, $x$ constant. If $(\rho_n)$ be a sequence of rational numbers with $$\lim \rho_n = x \Rightarrow \lim f(\rho_n) = \lim \rho_n/3 = x/3$$ If $(a_n)$ is a sequence of irrational numbers with $$\lim a_n = x \Rightarrow \lim f(a_n) = \lim a_n = x$$ then, it is $$\lim f(\rho_n)\neq\lim f(a_n) \Leftrightarrow x \neq 0$$ Thus, $f$ is not continuous at $\mathbb R \setminus \{0\}$.
We will now show that $f$ is continuous at $0$. It is $f(0) =0$. For all $|x| < 1$, we have : $$|f(x) - f(0)| = |f(x)| \leq \max\{|x|,|x|/3\} = |x|$$ thus $\lim_{x\to 0} f(x) = f(0)$ which means that $f$ is continuous at $0$.