TITLE: Give an example of a function $f: \mathbb{R} \to \mathbb{R}$ which is continuous only at $0$.
QUESTION [6 upvotes]: I do not know an example. Will ask question if in doubt of the proofs provided thank you!!

REPLY [4 votes]: $$
F(x) = \left\{
\begin{array}{rcl}
x,& \mbox{if} & x \in \mathbb{Q}\\
-x , & \mbox{if} & x \notin \mathbb{Q} \\
\end{array}
\right.
$$
$|x-0| < \varepsilon \Rightarrow |f(x) - f(0)| = |x| <\varepsilon$. If $x_0 > 0$. There is $x \notin \mathbb{Q}$ sufficiently  near $x_0$  such that $f(x) = -x$ is sufficiently  near $-x_0$. Thus do not sufficiently  near $f(x_0) = x_0$.