TITLE: Showing range is countable
QUESTION [5 upvotes]: Let $f: \mathbb{R} \to \mathbb{R}$.  For every $x \in \mathbb{R}$, there exists $\delta$, for every $y \in N(x, \delta)$ ($N$ stands for neighborhood) $f(y) \geq f(x)$.
Show that the range of $f$ is countable.

REPLY [2 votes]: In other words, $f$ has a local minimum everywhere. More generally, the same result holds if $f$ has a local extremum everywhere; according to this (Problem 2010-4/B), the result can be found in several places in the literature (a proof is also provided).
Interestingly, as a corollary in the case where $f$ is further continuous, we get an answer to this question (note my answer given there).
EDIT (elaborating on the second part): Suppose that $f:\mathbb{R} \to \mathbb{R}$ is continuous and has a local extremum everywhere. From the latter property, it follows that the range of $f$ is countable. Hence we conclude from the intermediate value theorem that $f$ must be constant (for otherwise the range would be uncountable, a contradiction).