TITLE: If every real-valued continuous function is bounded on $X$ (metric space), then $X$ is compact.
QUESTION [53 upvotes]: Let $X$ be a metric space. Prove that if every continuous function $f: X \rightarrow \mathbb{R}$ is bounded, then $X$ is compact.
This has been asked before, but all the answers I have seen prove the contrapositive. Realistically, this may be the way to go, but is there way to exhibit an unbounded continuous function (under the assumption $X$ is not compact) without appealing to results beyond introductory real analysis (e.g., the solution I've seen involves the Tietze Extension theorem)?
Because we're working with metric spaces, it's clear that the assumption that $X$ is noncompact (towards proving contrapositive) will lead us to extract a sequence of points in the space with no convergent subsequences. But how can we infer the existence of an unbounded continuous on the space knowing only about some sequence of points in this space (without using anything too advanced)?

REPLY [26 votes]: Another approach: Assume $X$ is not compact, so that there exists a sequence $a_n$ in $X$ that has no converging subsequence, and denote $A$ to be the underlying set of this sequence. Define $f:A\to R$ via $f(a_n)=n$. It is continuous on A, and $A\subset X$ is a closed set, so by the Tietze extension theorem $f$ extends to a (non-bounded) function on all of $X$.