I was asked to prove the following statement:
Let $K \subseteq R^n$. show that $K$ is compact (meaning closed and bounded) if and only if every continuous function is bounded on $K$.
What I did:
Suppose $K$ is not bounded, and so, it is not compact. Then the function $\sum |x_i|$ is a continuous unbounded function on $K$. Via contrapositive, this shows that if every function is bounded, then $K$ is also bounded.
What I need help with:
Assume $K$ is not closed. I need to find a continuous and unbounded function on $K$.
that will prove that if every continuous function is bounded on $K$, then $K$ is compact.
after that, i still need to show that if $K$ is compact then every continuous function $f: K \to \mathbb R$ is bounded.
Would someone point me in the right direction?
Clarification: it's not homework. I am preparing for an exam.