Proving continuity at each irrational on the Modified Dirichlet function $$f(x)=\begin{cases}0 & \text{if } x\in\mathbb{R}\setminus\mathbb{Q}\\
\frac{1}{q} & \text{if } x=\frac{p}{q},\text{ where $p$ and $q$ are in lowest terms}\end{cases}$$
For the function above, how can I show that it is continuous at each irrational number?
My work/attempted proof:
Suppose $d$ is an irrational number in the domain of $f$, so $f(d)=0$. For $\epsilon >0,\ \exists k\ni\frac{1}{k}<\epsilon$, by the Archimedean Property. Then there are finitely many rational numbers in the domain of $f$, such that their denominators are less than $k$. So, there exists a $\delta>0$ such that all rationals in $(d-\delta,d+\delta)$ have a denominator greater than or equal to $k$. It then follows that if $x$ is in the domain of $f$, then $|x-d|<\delta\implies|f(x)-f(d)|=|f(x)|<\frac{1}{k}<\epsilon$. Thus, $f$ is continuous at $d$. $\blacksquare$
 A: You need to show that for any $\epsilon > 0$ and any irrational $a$, there is a neighborhood $I$ of $a$ in which $|f(x)| < \epsilon$. Clearly the troublesome points here are the rational points of the neighborhood $I$. Let $n$ be a positive integer such that $n > 1/\epsilon$. Now consider any rational number of the form $p/n!$. It includes all the rationals whose denominator is from set $\{1, 2, \ldots, n\}$ (and many other rationals too). Now we can choose positive integer $p$ such that $p < n!a < p + 1$. Note that this is possible because $a$ is irrational (if $a$ were rational then one of these inequalities might become an equality). It follows that $$\frac{p}{n!} < a < \frac{p + 1}{n!}$$ Let $I$ be the interval $(p/n!, (p + 1)/n!)$. It should now be obvious that any rational number contained in $I$ must have its denominator greater than $n$ and hence at these rational points the value of $f(x)$ is $1/n < \epsilon$. So we get $|f(x)| < \epsilon$ as desired. Thus $f$ is continuous at $a$.
A: Your function isn't continuous anywhere, you can always find a sequence of rationals converging to an irrational and vice versa. So taking a rational approximation your function will be always $1$ and then become $0$ at an irrational.
If you take the modified where $f(x)=\frac{1}{q}$ where $x=\frac{p}{q}$ and this is in lowest part, then it is called Thomae's function and the idea to proof it is continuous in the irrationals, that if you choose a small neighborhood about your x value. If your $x$ is irrational for every positive integer $z$ there will be always an unique $k\in \mathbb{Z}$ such that 
$$k \cdot \frac{1}{z} < x< (k+1)\cdot \frac{1}{z}$$ 
So if you choose a neighborhoud you can always find a minimal $z$ and by making the neighborhood smaller this $z$ has to grow. 
