There exists a continuous function $f:U \to \mathbb{R}$ unbounded??

general-topologyreal-analysis

I am studying Real Analysis and I had a exam last week. In that test there was the question below:

Let $U \subset \mathbb{R}^n$ a non compact set. Show that there exists continuous function $f: U \to \mathbb{R}$, such that $f$ is unbounded.

So I tried to show that if every $f:U \to \mathbb{R}$ continuous is bounded then $U$ is compact.

I have proved that $U$ is bounded, but how can I prove that $U$ is closed???
It's just for curiosity because the test was last week.

Best Answer

HINT: If $a\in\Bbb R^n$ is in the closure of $U$ but not in $U$, consider the function $f(x) = 1/\|x-a\|$.

Related Question