TITLE: Pointwise limit of integrable function
QUESTION [13 upvotes]: Question:

Show that the pointwise limit of integrable functions is not necessarily integrable.

I am stuck on this question. Here is what I know.
Let $(f_n)^{\infty}_{n=1}$ be a series of integrable functions, and let 
$$\lim_{n \to \infty} f_n(x)=Z$$
I need to show that $Z$ is not necessarily integrable. Should I be looking for a specific example? A function that is integrable, but as $n \to \infty $ the function is no longer integrable.

REPLY [16 votes]: Just in case your question is about Riemann integrability, I will provide a sequence of Riemann integrable functions $f_n\colon[0,1]\to\mathbb{R}$ such that $\lim_{n\to\infty}f_n(x)=f(x)$ exists for all $x\in[0,1]$ but $f$ is not integrable in the sense of Riemann.
Order the rationals in $[0,1]$:
$$
[0,1]\cap\mathbb{Q}=\{r_n\}_{n=1}^\infty.
$$
Let
$$
\phi_n(x)=\begin{cases}
1 &\text{if }x=r_n,\\
0 &\text{otherwise}
\end{cases}
\quad\text{and}\quad f_n(x)=\sum_{k=1}^n\phi_k(x).
$$
Then $f_n$ is Riemann integrable, since it has a finite number of discontinuities ($r_1,\dots,r_n$), but
$$
f(x)=\lim_{n\to\infty}f_n(x)=\sum_{k=1}^\infty\phi_k(x)=\begin{cases}
1 &\text{if }x\text{ is rational}\\
0 &\text{if }x\text{ is irrational}
\end{cases}
$$
is not Riemann integrable (althoug it is Lebesgue integrable).