$\epsilon$-$\delta$ proof that $f$ is continuous for $x\notin\mathbb Q$ but isn't for $x\in\mathbb Q$ I'm trying to give an $\epsilon$-$\delta$ proof that the following function $f$ is continuous for $x\notin\mathbb Q$ but isn't for $x\in\mathbb Q$. 
Let $f:\mathbb{A\subset R\to R}, \mathbb{A=\{x\in R| x>0\}}$ be given by:
$$
  f(x) = \begin{cases}
1/n,&x=m/n\in\mathbb Q
\\
0,&x\notin\mathbb Q
\end{cases}
$$
where $m/n$ is in the lowest terms.
Can anyone help me with this proof (I'd prefer an answer with an $\epsilon$-$\delta$ proof).
Thank you very much!
 A: HINTS: To show that $f$ is continuous at an irrational $x$, show for any $n\in\Bbb Z^+$ you can choose $\delta>0$ small enough so that the interval $(x-\delta,x+\delta)$ contains no fraction with a denominator $\le n$ in lowest term. Use the fact that between two rationals with denominator $m$ there is a gap of at least $\frac1m$.
To show that $x$ is discontinuous at a rational $\frac{m}n$, let $\epsilon=\frac{m}n$ (or any smaller positive real), and just observe that every non-empty open interval in $\Bbb R$ contains an irrational number.
A: For $x=\frac mn\in\mathbb Q$ select $\epsilon=\frac1{2n}>0$. Assume there is $\delta>0$ such that $|x-y|<\delta$ implies $|f(y)-f(x)|<\epsilon$. 
Then especially $f(y)>\frac{1}{2n}$ for such $y$, which means that alls such $y$ are rational and have denominator $<2n$. Even without knowing that the irrationals are dense, we can see that $y=\frac ab$ with $b<2n$ and $y\ne x$ implies
$$|y-x|=\frac{|an-bm|}{bn}\ge \frac1{bn}>\frac1{2n^2}$$
because the numerator must be $\ge 1$. But of course there are (rational) numbers $y$ with $|y-x|\le \frac1{2n^2}$ (for example $y=x+\frac1{2n^2+1}$), hence no such $\delta$ exists, $f$ is not continuous.
Let $x\notin\mathbb Q$ and $\epsilon>0$ be given.
We want a $\delta>0$ such that $|y-x|<\delta$ implies $|f(y)-f(x)|<\epsilon$.
Select $n>\frac1\epsilon$. Then we want that $|y-x|<\delta$ implies that $y$ is either irrational or has a denominator $\ge n$.
For each $k< n$, there are only finitely many rationals $\frac mk$ with denominator $k$ and $|\frac mk-x|<1$. Then
$$\delta =\min\left\{\left|\frac mk-x\right|\colon k<n, \left|\frac mk-x\right|<1\right\} $$
will do the trick.
A: We prove that for every $a\in(0,1)$ we have $$\lim_{x\to a}f(x)=0$$
from where we'll see it is only continuous at the irrational points. So, let's pick any $a\in(0,1)$, and let us be given $\epsilon >0$. Choose $n$ so that $1/n\leq \epsilon$. 
First, we note that the only points where it might be false that $|f(x)-0|<\epsilon$ are $$\frac{1}{2};\frac{1}{3},\frac{2}{3};\frac{1}{4},\frac{3}{4};\frac{1}{5},\frac{2}{5},\frac{3}{5},\frac{4}{5}; \cdots ;\frac{1}{n}, \cdots ,\frac{{n - 1}}{n}$$ If $a$ is rational, then $a$ could be one of those numbers. But, as many as there can be, the amountof these numbers are finite. Thus, for some $p/q$ in that list, the number $$|a-p/q|$$ is least. If $a$ is one of these numbers, consider $p/q\neq a$. Then, take $\delta$ as this distance. It will then be the case that if $0<|x-a|<\delta$, then $x$ will be none of the numbers
$$\frac{1}{2};\frac{1}{3},\frac{2}{3};\frac{1}{4},\frac{3}{4};\frac{1}{5},\frac{2}{5},\frac{3}{5},\frac{4}{5}; \cdots ;\frac{1}{n}, \cdots ,\frac{{n - 1}}{n}$$
thus it will be true that $|f(x)-0|<\epsilon$. 
You can find another interesting example here.
