TITLE: If $f_n(x_n) \to f(x)$ whenever $x_n \to x$, show that $f$ is continuous
QUESTION [15 upvotes]: From Pugh's analysis book, prelim problem 57 from Chapter 4:

Let $f$ and $f_n$ be functions from $\Bbb R$ to $\Bbb R$. Assume that $f_n(x_n)\to f(x)$ as $n\to\infty$ whenever $x_n\to x$. Prove that $f$ is continuous. (Note: the functions $f_n$ are not assumed to be continuous.)

here's my attempt: assume $x_n \to x$. we want to show that $f(x_n) \to f(x)$. so $|f(x_n) - f(x)| \leq |f(x_n)-f_n(x_n)| + |f_n(x_n)-f(x)|$. The second term can be made to be less than any $\varepsilon > 0$ for $n$ sufficiently large. i'm having trouble with the first term. can anyone help? thank you!

REPLY [12 votes]: Suppose $(x_n)$ converges to $x$ and let $\epsilon>0$. 
Note that the hypotheses imply $(f_n)$ converges to $f$ pointwise. From this, choose a subsequence  $(f_{n_k})$ of $(f_n)$ such that
$$ |f_{n_k} (x_k) -f(x_k)|<\epsilon$$ for every $k$.
Claim: $f_{n_k}(x_k)$ converges to $f(x)$.
Proof of Claim: Consider the sequence $(y_n)$
$$(y_n)=
(\underbrace{x_1,x_1,\ldots,x_1}_{n_1\text{-terms}}\,,\,
\underbrace{x_2,x_2,\ldots,x_2}_{n_2-n_1\text{-terms}}\,,\,
\underbrace{x_3,x_3,\ldots,x_3}_{n_3- n_2 \text{-terms}},\ldots).
$$ 
Since this sequence converges to $x$, we have $f_n(y_n)\rightarrow f(x)$. Thus $f_{n_k}(y_{n_k})=f_{n_k}(x_k)\rightarrow f(x)$.

Now use the Claim and the inequality:
$$
|f(x_k)-f(x)|
\le |f(x_k)-f_{n_k}(x_k)|+|f_{n_k}(x_k)-f(x)|.
$$