Integrating a function with an infinite number of discontinuities I would appreciate some help with the following exercise:
Let
$$f(x)=\begin{cases} 1 & \text{if}\ x= 1/n\ \text{for some}\ n \in \mathbb{N} \\ 0 & \text{otherwise} \end{cases}$$
Show that $f$ is integrable in $[0,1]$ and compute $\int_{0}^1 f$.

Now, the lower sum is $0$ for every partition $P$, as every interval contains points where $f(x)=0$. It then remains to show that the upper sum is also $0$. 
This is the part I do not know how to handle. The phrasing of the exercise baffles me as it seems to me that there is an infinite number of discontinuities, .i.e. points where $f(x)=1$, and I have only encountered instances with finite discontinuities.
Thank you in advance.
 A: Hint: The key here is to notice that, given $\varepsilon > 0$, you can cover up the points $1/n$ with finitely many intervals such that the sum of the "widths" of these intervals is at most $\varepsilon$.
A: This is just $f \equiv 0$ redefined on a set of Lebesgue measure zero, so $$\int_{0}^1 f(x) dx = 0$$
A: If you know how to handle finite points of discountinuity, you can do as follows. To have the idea clear, fix an $n$, then in $\left[0, \frac{1}{n}\right]$ you can take the function $1$. In $\left[\frac{1}{n}, \frac{1}{2}\left(\frac{1}{n-1}+\frac{1}{n}\right)\right]$ consider the linear function which takes value $1$ in $\frac{1}{n}$ and $0$ in $\frac{1}{2}\left(\frac{1}{n-1}+\frac{1}{n}\right)$. Then, till now you have a function whose integral is $\frac{1}{n} + \frac{1}{4n}\left(\frac{1}{n-1}+\frac{1}{n}\right)$. The piece right in $\left[\frac{1}{2}\left(\frac{1}{n-1}+\frac{1}{n}\right),1\right]$has a finite number of discontinuites, so you can face it. But require that the function you take has integral $I$ such that $0 \leq I \leq \frac{1}{n}$. And impose it has value $0$ in $\frac{1}{2}\left(\frac{1}{n-1}+\frac{1}{n}\right)$, so that you can patch everything.
Now consider the succession of functions we get this way. Then the limit of integrals $J_{n}$ is $0 \leq J_{n} \leq \frac{1}{n} + \frac{1}{4n}\left(\frac{1}{n-1}+\frac{1}{n}\right) + \frac{1}{n} \to 0$.
