Suppose $f(x) = \begin{cases} 0 \ \ \text{if} \ x \in \mathbb{R}- \mathbb{Q} \newline \frac{1}{q} \ \ \text{if} \ x \in \mathbb{Q} \ \text{and} \ x = \frac{p}{q} \ \text{in lowest terms} \end{cases}$
(i) Is $f$ continuous on the irrationals? (ii) Is $f$ continuous on the rationals?
For (i) you could use the sequence definition of continuity? Maybe try $a_n = \frac{\sqrt{2}}{n}$ and show that $a_n \to 0$ but $f(a_n) \not \to 0$? So its discontinuous on the irrationals?
For (ii) I don't see why there are $1+2+ \cdots + (q-1)$ rational numbers? I know that we need to use this fact to choose an appropriate $\delta$ (e.g $0< |x-a| < \delta \Rightarrow |f(x)-L| < \epsilon$).