How to prove this function is continuous Consider the following function on $[0,1]$: $$  f(x) =
\begin{cases}
1/m,  & \text{if $x={m\over n} \in \Bbb Q$} \\
0, & \text{if $x$ $\notin \Bbb Q$}  \\
\end{cases}$$
Here, as usual, $\Bbb Q$ is the collection of all rational numbers and we assume that $m$ and $n$ have no common divisors. Prove that the function $f$ is continuous at any point $x \in [0,1]$\ $\Bbb Q$ . (any irrationals in $[0,1]$)
Please give a rigorous proof, or you can just give me a hint.
 A: Hint Let $x$ be any irrational in $(0,1)$. Then for any $n >0$ there are only finitely many fractions in $(0,1)$ whose denominator is less than $n$. Thus you can find one of them, lets call it $\frac{k}{m}$ which is closest to $x$. 
But then if $y$ is closer than $\frac km$ to $x$, then either $y$ is irrational, or is rational and has a denominator larger than $n$.
This is the main idea of the proof, you should be able to write it easily now with $\epsilon, \delta$...
A: It suffices to show that if $r\in [0,1]$ is irrational and $(q_i)$ is a sequence in $[0,1]$ converging to $r$, then $\lim\limits_{i\to\infty} f(q_i)=f(r)=0$. Since $f(q_i)=0$ for any irrational $q_i$, we can ignore the irrationals and assume $q_i$ is rational for all $i$, so we write $q_i=m_i/n_i$. For each $n\in\mathbb N$, let $X_n=\{m/k\in [0,1]:0<k\leq n\}$. Note that $X_n$ is finite and that $r\notin X_n$, so we have some $\epsilon>0$ such that $|r-m/k|>\epsilon$ for all $m/k\in X_n$. Since $m_i/n_i\to r$ we have some $N\in\mathbb N$ such that $i\geq N \implies |r-m_i/n_i|<\epsilon$, thus $i\geq N\implies n_i>n$. If we choose $N$ such that $i\geq N|\implies |r-m_i/n_i|>r/2$, we get that $m_i/n_i>r/2$ and so $m_i>nr/2$, thus $f(m_i/n_i)<\frac{2}{nr}$. Letting $n\to \infty$ we see that the $f(m_i/n_i)\to 0$, as desired.
