Checking continuity of Rational vs irrational functions Suppose we have a function $F$ defined by: 
$$F(x) = \begin{cases}
          0 & \text{if $x$ is irrational, and} \\
          1/n & \text{if $x = m/n \in \mathbb{Q}$, where $m/n$ is irreducible $m,n>0$.}
\end{cases}$$
I have a feeling that this function is discontinuous everywhere but my exam paper solution states that it is continuous at every irrational number.  
I racked my brains but still didn't see how this could be true at all. 
Please someone try to show how this can be true. Any hint will do. 
 A: Hint: Given  $\epsilon > 0$, what $x$ are there with $f(x) > \epsilon$?  Show that if $y$ is irrational, there is some $\delta > 0$ so that all of these are at distance more than $\delta$ from $y$.  
A: Hint: think about an irrational number like $\sqrt{2}$. $F(x)$ is $0$ for irrational $x$ near $\sqrt{2}$ and is small for rational $x$ near $\sqrt{2}$ (because a good approximation $m/n$ to $\sqrt{2}$ will have $n$ large, so that $1/n$ will be small). So $F(x)$ tends to $0$ as $x$ tends to $\sqrt{2}$.
A: Let $x\in \Bbb R$ \ $\Bbb Q.$
For $n\in \Bbb Z^+$ let $S_n=\{a/b: a\in \Bbb Z\land n\ge b\in \Bbb Z^+\}.$ Note we do not require $a,b$ to be co-prime in the def'n of $S_n.$
(1). We show that for each $n\in \Bbb Z^+$ there exists $\delta_n>0$ such that $S_n\cap (-\delta_n+x,\delta_n+x)=\emptyset.$
(2). We use (1) to show that $F$ is continuous at $x,$ as follows: Given $\epsilon>0,$ take $n\in \Bbb Z^+$ large enough that $1/n<\epsilon.$ Then take $\delta_n$ as in (1).
Now if $y\in  (-\delta_n+x,\delta_n+x)\cap \Bbb Q$ then $y\not \in S_n,$ so if $y=a/b$ with $a\in \Bbb Z$ and $b\in \Bbb Z^+$ and $\gcd (a,b)=1$ then $b>n$... (otherwise $y=a/b \in S_n$)... so $|F(y)-F(x)|=F(y)=1/b<1/n<\epsilon.$
And if $y\in (-\delta_n+x,\delta_n+x)$ \ $\Bbb Q$ then (obviously) $|F(y)-F(x)|=0<\epsilon.$
Therefore $$\delta_n>0\land \forall y\, (\,|y-x|<\delta_n\implies |F(y)-F(x)|<\epsilon).$$
(1*). There are many ways to prove (1). Let $T_n=\{a/(n!):a\in \Bbb Z\}.$  Since $x\not \in \Bbb Q$ there exists $a_n\in \Bbb Z$ with $a_n/(n!)<x<(1+a_n)/(n!).$ So let $\delta_n=\min (x-a_n/(n!),\,(1+a_n)/(n!)-x\,).$ Since $S_n\subseteq T_n,$ we have $y\in S_n\implies y\in T_n\implies |y-x|\ge \delta_n.$ Note  we do not need a "good" estimate for $\inf \{|y-x|: y\in S_n\}$; we merely need that it is not $0.$
