# Compactness implies Continuity?

I am stuck on this question (probably there are many counterexamples, but I can't find any).

"Suppose $f:\mathbb{R}\mapsto\mathbb{R}$ that preserves compactness (i.e, for every $K \subseteq R$, then $f(K)$ is compact). Is $f$ continuous?"

thanks!

-
Just wanted to point out that the inverse direction is indeed true: the image of a compact set $K\subset\mathbb{R}$ under a continuous function $f$ is compact (iow $f(K)\subset\mathbb{R}$ is compact). $\ddot\smile$ –  b00n heT Jan 31 '14 at 22:19

$f(x) = 1$ if $x$ is rational, otherwise $f(x)=0.$ So $f(K)$ is either one or two points.
@Dror: I am talking about functions $\Bbb{R\to R}$. There are only $2^{\aleph_0}$ functions which are Borel (which turn out the be the smallest class of functions containing all the continuous functions and closed under pointwise limits), so most of the functions are even "less continuous" than that. If you want to be slightly more "specific", pick any non-measurable subset, e.g. a Bernstein set or a Vitali set, and consider its indicator function. –  Asaf Karagila Jan 31 '14 at 22:36