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

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.

• What if $U=\mathbb R$? Can you think of an unbounded continuous function $f:\mathbb R\to\mathbb R$? What's your favourite continuous function on $\mathbb R$? – Dave Sep 21 '19 at 2:48
• This is trivial, it is the identity. I have thought this but... – Joãonani Sep 21 '19 at 2:50

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\|$$.