# A continuous integer-valued function on a compact metric space has finite range

Let $$X$$ be a compact metric space and let $$f:X\to\mathbb Z$$ be a continuous function. (Here $$\mathbb Z$$ has the Euclidean topology induced from $$\mathbb R$$.) Prove that $$f$$ can assume only finitely many values.

### Idea

I'm thinking about using Weierstrass's theorem to a show a $$c$$ exists such that $$f(c) = \sup \{f(x): x \in X\}$$ and as a result $$f$$ can only have finite values?

• im thinking about using weierstrass's theorem to a show a c exists such that f(c) = sup (f(x): x in X) and as a result f can only have finite values?? Dec 8 '14 at 17:55
• Oh, $Z$ is the set of integers? The continuous image of a compact set is... Dec 8 '14 at 18:00

Because $f$ is continuous and $X$ is compact then $f(X) \subseteq \mathbb{Z}$ is a compact set, and compact sets in $\mathbb{Z}$ are finite, why? Suppose $C$ is infinite set of integers, then the space is not compact, just pick the balls with radii less than $1$ centered at points of $C$, this would contradict the space being compact as it is an open cover with no finite subcover.