Continuous functions that pointwise converge to zero, but the integral tending towards infinity.

I wish to find a continuous function $f_n:[0,1]\rightarrow\mathbb{R}$ such that $f$ converges pointwise to 0, but also $\int^1_0f_n\rightarrow\infty$

Then another $f_n:[0,\infty)\rightarrow\mathbb{R}$ continuous satisfying $||f_n||_\infty\rightarrow 0$ but with $\int_0^\infty f_n=1$

For the first one every point in 0 to 1 must converge to 0, but the area underneath them must not (which really confuses me because $f$ is continuous, it can’t jump)

For the second one, the sup norm tending towards zero means the largest value $f_n$ takes must tend towards zero, but the area must be 1. I’m thinking of some sort of function that spreads out might work but keeping it continuous is the difficult part.

I’ve been thinking for over an hour (I hate to admit) and really quite stumped, this is a past exam question (no solutions available) and I have no ideas left about how to find such a function.

I’ve been looking for a theorem to negate or abuse so I can get a definition I must get a function to satisfy, which is really hard with the continuous constraint.

Solutions Collecting From Web of "Continuous functions that pointwise converge to zero, but the integral tending towards infinity."

For the first question, consider on the interval $[0, \frac{2}{n}]$ the isosceles triangle with height $n^{3}$. Then I leave to you to calculate the function (there are two linear parts and then zero) and to check it converges to zero.

For the second problem you can rearrange the functions $\frac{1}{n}\chi_{[0,n]}$ in a way it is continuous and has integral $1$ (you can do again with a linear part to join the two constant parts).

Let $$g(x)=\begin{cases}x&\text{if }0\le x\le 1\\
2-x&\text{if }1\le x\le 2\\
0&\text{if }x\ge 2\end{cases}$$
and then $f_n(x)=n^2g(nx)$ for the first problem and $f_n(x)=\frac1ng(x/n)$ for the second problem.