I have to prove that the function $f:]0,1] \rightarrow \Bbb R$ : $$ f(x) = \begin{cases} \frac1q, & \text{if $x \in \Bbb Q$ with $ x=\frac{p}q$ for $p,q \in \Bbb N$ coprime} \\ 0, & \text{if $x \notin \Bbb Q $} \end{cases} $$
is continuous in $x \in \ ]0,1] \backslash \Bbb Q$ (irrational numbers).
I already tried to solve this exercise and I understood how to prove that this function is discontinuous for rational numbers. I was trying, now, to understand how to prove that for the irrational numbers it is continuous.
I already have the solutions but they are a bit complicated, and I come up using sequences to prove it's continuous: $$\forall x_n \quad x_n\rightarrow a \quad \Rightarrow \quad f(x_n) \rightarrow f(a)$$
I created a sequence $ x_n=\frac1n + a$, and we consider $a$ an irrational number. In order to be continuous $f(x_n)$ has to converge to $f(a)$. In fact:
$$\lim_{n\to\infty} f(x_n)= f(a) = 0 $$
So my proof ends here, but I know that I'm missing something really big because in the solution there is another complicated step using a set and the Epsilon-Delta theorem after what I've showed.
Can someone explain what's wrong and help me with this proof?