# About necessary and sufficient condition in compact metric space

Let $X$ be a metric space. Show that all continuous functions from $X$ to $\Bbb R$ are bounded iff $X$ is compact.

-
See the first answer here for the non-trivial implication. –  David Mitra Oct 1 '12 at 19:40

## 1 Answer

The hardest direction is the "only if". If $X$ is not compact, we can find a sequence $\{x_n\}$ without converging subsequence. Pick for each $n$ a positive number $r_n$ such that the balls $B(x_n,r_n)$ are pairwise disjoint (work by induction, and using the fact there are no converging subsequences).

Then we define $f_n(x):=\frac 1{r_n}\max(r_n-d(x,x_n),0)$, which is continuous and $f(x):=\sum_{j=0}^{+\infty}jf_j(x)$. The sum is convergent, as for each $x$, $f_n(x)\neq 0$ for at most one $n$, and it defines a continuous function, as the same $n$ works in a small neighborhood of the considered point $x$. But this function is not bounded, as $f(x_n)=n$.

-