Continuity of Popcorn Function (Thomae's Function) 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?
 A: Working with sequences you would have to prove that for all sequences $x_n\to a$ one has $\lim_{n\to\infty}f(x_n)=f(a)=0$.
A direct $\epsilon$-$\delta$-proof is much simpler.
Let an $\epsilon>0$ be given. There is an $N\in{\mathbb N}$ with ${1\over N}<\epsilon$. The set
$$Q:=\left\{{k\over n}\>\biggm|\>1\leq n\leq N, \ k\in{\mathbb Z}\right\}$$
of all rationals with a denominator $\leq N$ is discrete, and does not contain the irrational $a$. It follows that $Q$ contains a point nearest to $a$, and $$\delta:=\min_{x\in Q}|x-a|>0\ .$$
I claim that $|f(x)|<\epsilon$ for all $x$ with $|x-a|<\delta$. 
Proof. If $x\in\ ]a-\delta, a+\delta[\ $ is irrational then $f(x)=0$ by definition of $f$. If this $x$ is rational then certainly $x\notin Q$, hence $x={p\over q}$ with $q>N$. It follows that $|f(x)|={1\over q}<{1\over N}<\epsilon$.
A: It suffices to show that $\lim_{t\to x}f(t)=0$ for any $x\in\Bbb R$.
$\underline{\forall x\in\Bbb R,f(x-)=0}$.
Let $\epsilon>0$ and choose $N\in\Bbb N_+$ such that $1/N<\epsilon$.  For each $n\in\Bbb N_+$, let
$$\begin{align}
m_n & =\max\left\{m\in\Bbb Z:\frac mn<x\right\}\\
q_n & =\frac{m_n}n\quad\text{and,}\\
M_n & = \left\{\frac mn:\frac mn<x\right\}.
\end{align}$$
For any $1\le n\le N$, we have that $M_n\cap [q_n,x)=\emptyset$ or $M_n\cap [q_n,x)=\{q_n\}$, since $\frac{m_n+1}n\ge x$.  Therefore the set $$M=\bigcup_{k=1}^N M_k\cap[q_N,x)$$
is finite and we can define
$$\delta=\min\{x-q:q\in M\}.$$
Now suppose $0<x-t<\delta$ for some $t\in\Bbb R$.  If $t\in\Bbb Q$, then $t=m/n$ with $n>N$, and $f(t)=1/n<\epsilon$.  If $t\notin\Bbb Q$, then $f(t)=0<\epsilon$.
$\underline{\forall x\in\Bbb R, f(x+)=0}$.
Let $\epsilon$ and $N$ be as above and define
$$\begin{align}
m_n & =\min\left\{m\in\Bbb Z:\frac mn>x\right\}\\
q_n & =\frac{m_n}n\\
M_n & =\left\{\frac mn:\frac mn>x\right\}.
\end{align}$$
The proof now follows along the sames lines as the previous claim.
