If $f_n(x_n) \to f(x)$ whenever $x_n \to x$, show that $f$ is continuous 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!
 A: Here's a hint: fix $n$ and consider the constant sequence $x_m = x_n$ for all $m$. This converges to $x_n$, so your assumption tells you that $f_m(x_n)$ converges to $f(x_n)$ as $m \to \infty$. Now look at building inequalities involving things like $f_m(x_n)$, and don't forget that convergent sequences are also Cauchy.
A: 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)|.
$$
A: Nice Problem. $\newcommand\abs[1]{\left\lvert#1\right\rvert}$There's another approach:
Suppose $\{x_n\}$ is an arbitrary sequence which converges to $x$. It suffices to prove that
$$f(x_n)\to f(x)\tag{*}$$
The key is to construct an increasing integer sequence $0<N_1<N_2<\dotsb$ such that
$$\abs{f_{N_k}(x_k+1/N_k)-f(x_k)}<1/k\tag1$$
We'll construct terms inductively.
Put $N_0=0$, and suppose $N_0,\dotsc,N_{k-1}$ are constructed. Now consider sequence $\{f_m(x_k+1/m)\}$. Since $x_k+1/m\to x_k$ as $m\to\infty$, we have
$$\lim_{m\to\infty}f_m(x_k+1/m)=f(x_k)$$
So there's some $N_k>N_{k-1}$ such that $\abs{f_{N_k}(x_k+1/N_k)-f(x_k)}<1/k$.
Now let's consider sequence, namely $\{a_n\}$: $x_1+1/N_1,\dotsc,x_1+1/N_1,x_2+1/N_2,\dotsc,x_2+1/N_2,\dotsc$. $x_1+1/N_1$ appears $N_1-N_0$ times, followed by $x_2+1/N_2$ with $N_2-N_1$ times, then $x_3+1/N_3$ with $N_3-N_2$ times, and so forth, we have $a_n\to x$, so $f_n(a_n)\to f(x)$ as $n\to\infty$
Notice that $a_{N_k}=x_k+1/N_k$, and $f_{N_k}(a_{N_k})=f_{N_k}(x_k+1/N_k)$, therefore
$$\lim_{k\to\infty}f_{N_k}(x_k+1/N_k)=f(x)\tag2$$
(*) follow from (1) and (2)
A: Note that $f_{n}(x) \to f(x)$ for all $x$.
Assume that f is discontinuous at a.This means that
there is a sequence $x_n \to a$ while 
$f(x_n)\notin [f(a)-2\epsilon ,f(a)+2\epsilon]    $  for some $\epsilon>0 $.  
Then construct another sequence $y_n $ as follows: 
$y_1=y_2=...=y_{N_1}=x_1 $   where $ |f_{N_1}(x_1) -f(a)|>\epsilon$
$y_{N_1+1}=y_{N_1+2}=...=y_{N_{2}}=x_2$ where $ |f_{N_2}(x_2)-f(a)|>\epsilon$ and $N_2>N_1$
...
Now  ,  $y_n\to a$ but $f_n(y_n)\to\neq f(a)$ !                    
So , we get a contradiction.
f is continuous.
