# How do i show that if every continuous function on $X$ is bounded, then $X$ is compact? [duplicate]

Let $$(X,d)$$ be a metric space.

Assume every continuous function on $$X$$ is bounded.

Prove that $$X$$ is compact.

Well, i don't know which continuous function should i fix to start an argument.

I tried to fix a function $$f(x)=d(x,x_0)$$, but i think it doesn't work.

How do i prove this?

By contradiction. Suppose $X$ is not compact; therefore one can pick an infinite sequence $x_1,x_2,...$ that does not accumulate at any point in $X$.
Then pick an unbounded function on that sequence, say $f(x_n)=n$, and turn it into a continuous one. This is possible because topology of a metric allows interpolation function between disjoint close subsets.
For example, you can enclose each $x_n$ into balls $x_n\in B_{\epsilon_n}$ such as $B_{\epsilon_n}$ are pairwise disjoint, then set $f(x)=0,x\in (X-\cup B_{\epsilon_n})$ and $f(x)=n(1-\frac{d(x,x_n)}{\epsilon_n}),x\in B_{\epsilon_n}$