TITLE: Functions that are continuous only at two points?
QUESTION [15 upvotes]: I need to find a function $f:\mathbb{R}\to\mathbb{R}$ which is continuous only at two points, but discontinuous everywhere else.
How on earth would I go about doing this? I can't think of any function like this.
Thanks in advance.
Edit: I've seen examples including the indicator function for rationals. Is this the only method of finding such functions?

REPLY [6 votes]: General answer. If you have $a(x)$ and $c(x)$ continuous and $b(x)$ nowhere continuous, then
$$a(x)\cdot b(x) + c(x)$$
is continuous at $x$, iff $a(x) = 0$.