# How can I prove that a function $f: \mathbb{R} \rightarrow \mathbb{N}$ is continuous only if $f$ is constant?

I have to find all functions of the type:

$$f: \mathbb{R} \rightarrow \mathbb{N}$$

that are continuous. The way I see it, such a function can only be continuous if it is a constant function like so

$$f(x) = n$$

for any $$x \in \mathbb{R}$$ and for some $$n \in \mathbb{N}$$. If this condition wouldn't be satisfied then the point where the value of the function changes to a different natural number (say that is changes from $$n$$ to another natural number $$m$$) would break continuity, because at that point we would have either a jump discontinuity or a removable discontinuity, so obviously the function wouldn't be continuous. If, on the other hand the function if constant, then it's natural to think that it is continuous (duh).

But how can I formalize my intuition? I was taught the definition of continuity in terms of neighborhoods. It goes something like this:

$$\forall V \in \mathcal{V}(f(c)), \exists U \in \mathcal{V}(c) \text{ such that } \forall x \in U \cap A \text{ we have } f(x) \in V$$

But I don't see how I could use this definition to prove my point (that is, if my intuition is correct!). So my question is this: How can I formalize my intuition and come up with a real, mathematical solution to this problem? I don't see how to manipulate the above definition in order to prove my point.

• Are you familiar with the equivalent definition in terms of $\epsilon$ and $\delta$? The proof is much easier via that definition! Commented Nov 7, 2020 at 19:08
• This question gives two answers: use connectivity; or use the intermediate value theorem. For example, one may regard all the details of manipulating the definition of continuity as being contained in the proof of the intermediate value theorem. Commented Nov 7, 2020 at 19:20
• @bounceback I'm not familiar with it but at least willing to learn it. How exactly would the proof go if we were to use the $\epsilon$ and $\delta$ definition?
– user719014
Commented Nov 7, 2020 at 20:57
• You could just take $\epsilon = 1/2$, and note that no positive $\delta$ does the trick. But there are plenty of excellent alternate proofs below, based upon the definition you propose Commented Nov 7, 2020 at 20:58

A continuous function preserves connectedness, $$\mathbb{R}$$ is connected and since $$\lbrace n\rbrace$$ is open in the discrete topology on $$\mathbb{N}$$, the image can't have more than a point.
The key insight is to note, for any $$n\in\Bbb N$$, that $$V=\{n\}$$ really is a neighborhood of $$n$$ in $$\Bbb N$$.
Take $$c\in\Bbb R$$. Then $$\{f(c)\}$$ is both a closed and an open subset of $$\Bbb N$$. So, $$f^{-1}\bigl(\{f(c)\}\bigr)$$ is both a closed and an open subset of $$\Bbb R$$. It is also non-empty, since it contains $$c$$. But, since $$\Bbb R$$ is connected, its only subset which is open, closed and non-empty is $$\Bbb R$$ itself. Therefore, for each $$x\in\Bbb R$$, $$f(x)=f(c)$$.
The image under a continuous real map $$f$$ of $$\mathbb R$$ is an interval. As the only intervals of $$\mathbb N$$ are singletons, $$f$$ has to be constant.