Solution (source code)

= Solution

At a nonzero rational $p/q$ in lowest terms, irrational points approach $p/q$ with function value zero, whereas $f(p/q)=1/q>0$, so $f$ is discontinuous. At zero, $|p/q|\geq1/q$ for nonzero $p$, hence $0\leq f(x)\leq|x|$ and continuity follows.

At an irrational $x$, given $\varepsilon>0$, only finitely many rationals in a bounded neighbourhood have reduced denominator $q\leq1/\varepsilon$. Choose a neighbourhood avoiding those points; throughout it, $f<\varepsilon$. Consequently the continuity set is \b[$(\mathbb R\setminus\mathbb Q)\cup\{0\}$]. This is a variant of the <Thomae function>.