Prove the following function is continuous at all irrational points $$f(x) = \begin{cases}
0, x \notin Q \\
\frac 1n, x = \frac mn, m,n \in Z
\end{cases}$$
Note that m and n are coprime. This an example from the book:- Introduction to real analysis by Robert G Bartle.
Between any two irrational numbers, we can find a rational number, so how can we say it's continuous at all irrational points?
Yes, it can converge to 0, but let's take root 2 as an eg, around that point, we have many points between 1 and 0.5 (at rationals)
Where am I thinking wrong?
 A: Suppose we take a sequence $a:\mathbb{N}\to\mathbb{R}$ and consider Heine definition of continuity i.e.

Let's say a function $f:\mathbb{R}\to\mathbb{R}$ is continious at the point $x_0$ iff for every sequence $a_n$ $\lim\limits_{n\to\infty}a_n=x_0\Rightarrow \lim\limits_{n\to\infty}f(a_n)=f(x_0)$

More formal:  

a function $f: X \to Y$ is sequentially continuous if whenever a sequence $(x_n)$ in $X$ converges to a limit $x$, the sequence $(f(x_n))$ converges to $f(x)$

So let's suppose $\lim\limits_{n\to\infty}a_n=a\in\mathbb{R}\setminus\mathbb{Q}$, but $\lim\limits_{n\to\infty}f(a_n)=\frac{1}{b}\ne 0$.
Let's consider $\lim\limits_{n\to\infty}\frac{1}{f(a_n)}=b\in\mathbb{Z}$, so, $\forall\varepsilon>0\,\exists N(\varepsilon):\,\forall n>N(\varepsilon)\, |\frac{1}{f(a_n)}-b|<\varepsilon$ and take $\varepsilon=\frac{1}{2}$, as $\frac{1}{f(a_n)}\in\mathbb{Z}$ so $|\frac{1}{f(a_n)}-b|<\frac{1}{2}\Rightarrow \frac{1}{f(a_n)}=b$,
so $\forall n>N(\frac{1}{2})\, \frac{1}{f(a_n)}=b$, so $\forall n>N(\frac{1}{2})\ a_n$ has the form $\frac{c_n}{b}$ where $c_n\in\mathbb{Z},\,\gcd(c_n,b)=1$ so $a$ can't be irrational because it's rational with denominator $b$, hence a contradiction.
More, if $\lim\limits_{n\to\infty}\frac{1}{f(a_n)}=b'\notin\mathbb{Z}$ we take $b$ as the nearest integer to $b'$ and the argument above works.
