Functions that are continuous only at two points? 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?
 A: What about 
$$
  f(x)
= \begin{cases}
  x(1-x) & x \in \mathbb{Q} \\
  0   & x \notin \mathbb{Q} \\
  \end{cases}?
$$
A: 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$.
A: Think of something like
$$f(x)=\begin{cases}
x^2 & \text{if } x \in \mathbb{Q}\\
x & \text{if } x \in \mathbb{R-Q}\\
\end{cases}
$$
This is only continuous at two points, namely where $x^2=x$.
A: The following function is a standard example of a function that is continuous at one point only:
$$
f(x) = \begin{cases} x &: x \in \Bbb Q \\
0 &: \text{ otherwise.}\end{cases}
$$
Show that this is indeed the case. Can you think of a way to modify it so that it's continuous at two points? Hint: 

 Instead of $x$ in the first case, consider the polynomial $(x - x_0)(x - x_1)$.

This can be generalized to construct a function that is continuous at a finite set of points only.
A: It is possible to use something other than the rational indicator function to define these functions.  Specifically, take $S$ to be a set define the function $I_S$ by
$$I_S(x) = \left\{\begin{array}{cc} 1 & x \in S\\ 0 & x \not\in S\end{array}\right.$$
This function is called the indicator function of $S$.  Now, let $S$ be a dense subset of $\mathbb{R}$ such that $S^C$ is also dense in $\mathbb{R}$.  (For example, we could take $S$ to be the set of all rational numbers with terminating decimal expansions.) Then, the function 
$$f(x) = x^2I_S(x) + x(1-I_{S}(x))$$
is continuous at only $x=0$ and $x=1.$
