TITLE: Prove that $\int_0^1 f(x)dx=0$ if $f(\frac{1}{n})=1$ for $n=1,2,3,\ldots$ and $f(x)=0$ for all other $x$
QUESTION [5 upvotes]: Prove that $\int_0^1 f(x)dx=0$ if $f(\frac{1}{n})=1$ for
  $n=1,2,3,\ldots$ and $f(x)=0$ for all other $x$.


Lemma: If $f:[a,b]\rightarrow \mathbb{R}$ is a function such that $f(x)=\mathbb{1}_{\{c\}}$ for some $a<c<b$, then $\int_a^b f(x)dx=0$.
Proof of the lemma:
Consider a partition of $[a,b]$ such that its width is less than $\delta>0$. Then the absolute value of Riemann sum corresponding to this partition is less than $2 \delta $. So for any $\epsilon>0$ we can choose $\delta=\frac{\epsilon}{2}$ and we will have $|S|<\epsilon$ whenever $S$ is a Riemann sum corresponding to a partition of width less than $\delta$.
Proof of the main result:
Choose $\epsilon>0$. From the above lemma and linearity of the Riemann integral, we know that $$\int_{\epsilon/2}^1f(x)dx=0 \mbox{.}$$
Thus there is a step function $g:[\frac{\epsilon}{2},1]\rightarrow \mathbb{R}$ such that $0\le f(x)\le g(x)$ for all $x\in[\frac{\epsilon}{2},1]$ and $$ \int_{\epsilon/2}^1 g(x)dx <\epsilon /2 \mbox{.}$$
Define a new step function $h:[0,1]\rightarrow \mathbb{R}$ such that $h(x)=g(x)$ if $x\in  [\frac{\epsilon}{2},1]$ and $h(x)=1$ if $x\in [0,\frac{\epsilon}{2})$. It is clear that for all $x\in [0,1]$ we have
$$0\le f(x) \le h(x) \mbox{.}$$
Also $$ \int_{0}^1 h(x)dx = \int_{0}^{\epsilon/2} dx  + \int_{\epsilon/2}^1 g(x)dx <\epsilon /2+ \epsilon /2 =\epsilon \mbox{.}$$
Thus we proved that $f$ is integrable. It remains to show that the integral $\int_0^1 f(x)dx$ is equal to $0$. We know that $\int_0^1 f(x)dx$ exists and however small $\alpha$ we choose, the integral $\int_{\alpha}^1 f(x)dx$ also exists and is equal to $0$. The result follows from continuity of the integral.
I would be very grateful if somebody verified my proof, I'm quite not sure about the very last part. Thank you.

REPLY [3 votes]: Your proof looks OK to me, perhaps a little long. At the end, you certainly can use continuity if you like, but I don't think you need to. You have $f$ Riemann integrable and $0\le f\le h.$ Thus $0\le\int_0^1f \le \int_0^1 h < \epsilon.$ Since $\epsilon$ is arbitrarily small, $\int_0^1f=0.$
The upper/lower sums approach to the Riemann integral might be a simpler route to the result. For $n\in \mathbb N,$ let $P_n$ be the uniform partion of $[0,1]$ into subintervals of length $1/n^2.$ We then have
$$0 = L(P_n,f)\le U(P_n,f) = \sum_{k=1}^{n^2}M_k\cdot \frac{1}{n^2} = \sum_{k=1}^{n}M_k\cdot \frac{1}{n^2} + \sum_{k=n+1}^{n^2}M_k\cdot \frac{1}{n^2}.$$
The first sum on the right is $\le n\cdot 1 \cdot (1/n^2).$ For the second sum, think about the points $1,1/2,\dots ,1/n.$ Each of these points can lie in at most two subintervals determined by $P_n.$ Thus the second sum is at most $2\cdot n\cdot 1 \cdot (1/n^2).$ Adding these up gives
$$0 = L(P_n,f)\le U(P_n,f) \le \frac{n+2n}{n^2} =\frac{3}{n}.$$
Letting $n\to \infty$ shows the difference between upper and lower sums can be made arbitrarily small, which implies $f$ is Riemann integrable on $[0,1].$ Because $U(P_n,f) \to 0$ and $\int_0^1f \le U(P_n,f) $ for any $n,$ we have $\int_0^1f = 0$ as desired.