TITLE: Condition for $\displaystyle \lim_{x\to 0}f(x)=\lim_{n\to\infty}f\left(\frac{1}{n}\right)$?
QUESTION [7 upvotes]: Let $f:{\Bbb R}\to{\Bbb R}$. Is there a courterexample for the following equality or is it always true?

$$\lim_{x\to 0}f(x)=\lim_{n\to\infty}f\left(\frac{1}{n}\right)$$

What I think is that one might need a non-continuous function since this is always true for a continuous function. Would $1_{\Bbb Q}$ work? Are there any other counterexamples?

REPLY [7 votes]: Actually, even for a function which is discontinuous at only one point, this need not be true. For example: $$f(x)=\begin{cases}\sin(\pi/x)&:x\neq0\\ 0&:x=0\end{cases}.$$ This equals $0$ for every $n\in\Bbb Z\setminus\{0\}$ as $\pi/(1/n)=n\pi$ but the limit as $x\to0$ does not exist. However, if the function is continuous, then yes, the limits will be equal. 
Thus, as you can see, the only way to guarantee the limits are equal is if $$\lim_{x\to0}f(x)$$ exists.

REPLY [5 votes]: If the left hand side limit exists, then both limits exist and are equal.  However, it is possible for the right hand side limit to exist and the left hand side limit not to exist (in which case $f$ must be discontinuous.) For example, let $f(x) = 1$ if $x = 1/n$ for some $n \in \mathbb{N}$ and $f(x) = 0$ otherwise.