Show function with infinitely many discontinuities is Riemann-integrable Prove that the following function is Riemann-integrable on $[0, 1]$ even though it has infinite many discontinuities on $[0, 1]$: $$f(x) = \begin{cases} 1 & \text{if } x = \frac1n \text{ where } n = 1, 2, 3, \ldots, \\ 0 & \text{otherwise}.\end{cases}$$
I have a possible proof but don't feel too confident about it. If anyone could tell me if its valid or give me another proof, or hints to another proof, that would be very helpful!

Let $\varepsilon > 0$.  Observe that given $\frac\varepsilon2$ there exists a least natural number $N$ with $\frac{1}{N+1} < \frac\varepsilon2$. Observe that there are $N$ numbers less than $N + 1$. Now we want to consider the two intervals $[0, \delta]$ and $[\delta, 1]$ with $0 < \delta < 1$ and $\delta = \frac\varepsilon2$.
Lets first consider the interval $[\delta, 1]$. Observe that there are exactly $N$ discontinuities on this interval, that is, $N$ elements of the form $\frac1n$ such that $\frac1N > \frac{1}{N+1}$. This interval is bounded since by construction $f$ is bounded above by 1 and bounded below by 0 and thus it is bounded. We have satisfied the hypothesis of Exercise 6.6 and thus we can conclude that $f$ is Riemann-integrable on $[\delta, 1]$. Moreover, since $f$ is Riemann-integrable on $[\delta, 1]$, by Theorem 6.1, we are assured that there exists a partition $P_2$ such that $U(P_2, f) - L(P_2, f) < \frac\varepsilon2$. Observe that the lower sum is 0 for any given partition, so we have $U(P_2, f) < \frac\varepsilon2$.
Now let us consider the interval $[0, \delta]$. Let $P_1$ be any partition of this set and observe that $$U(P, f) = \sum_{i = 1}^l M_i \, \Delta x_i < 1 \cdot \big( \frac\varepsilon2 - 0\big) = \frac\varepsilon2$$ since the supremum of the entire interval is 1, it must hold that 1 is an upper bound for any smaller interval. Moreover the length of the interval $[0, \delta]$ is $\delta$ which is defined to be $\frac\varepsilon2$. Again it still holds that the lower sum is 0. Thus we have $U(P_1, f) < \frac\varepsilon2$.
Now choose $P = P_1 \cup P_2$ to be a common refinement of $P_1$ and $P_2$ and observe that $$U(P, f) - L(P, f) = U(P, f) = U(P_1, f) + U(P_2, f) = \frac\varepsilon2 + \frac\varepsilon2 = \varepsilon$$
Thus by Theorem 6.1 $f$ is Riemann-integrable on $[0, 1]$.

 A: As mentioned in Michael Greinecker's comment, a nice way to go is to use the following result:
Theorem: Let $f: [a,b] \rightarrow \mathbb{R}$ be a bounded function.  If for all $c \in (a,b)$ the restriction of $f$ to $[c,b]$ is Riemann integrable, then $f$ is Riemann integrable on $[a,b]$ and $\int_a^b f = \lim_{c \rightarrow a^+} \int_c^b f$.
This result is proved in $\S 8.3.2$ of my honors calculus notes.
A: Let's prove the function is Darboux-integrable. Let $\epsilon > 0$ and $N \in \mathbb{N}$ such that $\frac{1}{N} < \frac{\epsilon}{2}$ and $\delta < \frac{\epsilon}{4N}$. Let $P=\{x_0,\ldots, x_n\}$ be a partition of $[0,1]$ with
$$x_1=\frac{1}{N}$$ and
$$|I_j|:=x_j-x_{j-1} \leq \delta, \ \forall j \geq 2$$
Hence, if $x=\frac{1}{N}$ is such that $x \geq x_1$, we need $n \leq N$. Therefore there is only $N$ discontinuities of $f$ (points that are $\frac{1}{n}$) that are excluded from $I_1=\left[0, \frac{1}{N} \right]$. Thus,
$$ \begin{split}
D(f,P)&:= \sum_{j=1}^n \sup_{x_{j-1} \leq \xi_{j}, \xi_{j}' \leq x_j}|f(\xi_j)-f(\xi_j')| \cdot (x_j-x_{j-1})\\
&=\sum_{j=1}^n \text{osc}_f(I_j) \cdot |I_j|\\
&= \text{osc}_f(I_1) \cdot |I_1|+\sum_{j \geq 2, \frac{1}{n} \in I_j}\text{osc}_f(I_j) \cdot |I_j|+ \sum_{j \geq 2, \frac{1}{n} \notin I_j}\text{osc}_f(I_j) \cdot |I_j|\\
&=\frac{1}{N}+\sum_{j \geq 2, \frac{1}{n} \in I_j} |I_j|
\end{split}$$
because
$$\text{osc}_f(I_j)=
\begin{cases} 1 & \text{if } \exists \frac{1}{n} \in I_j\\
0 & \text{otherwise}
\end{cases}$$
Hence,
$$D(f,P) < \frac{\epsilon}{2} + \sum_{j \geq 2, \frac{1}{n} \in I_j} \delta \leq \frac{\epsilon}{2} + 2N\delta$$
because each $N$ point (that is $\frac{1}{n}$) which is not in $I_1$ is at most in 2 $I_j$ intervals (generally speaking only in one). Therefore,
$$D(f,P) < \frac{\epsilon}{2}+ \frac{\epsilon}{2}=\epsilon$$
Thus $f$ is Riemann-integrable on $[0,1]$. 
