Proving Riemann integrability for piecewise function Question: Prove the function $f:[0,1] \to \mathbb R$ given by $f(x) = \begin{cases}
1,  & \text{if $x=\frac{1}{n}$ for any positive integer $n$} \\
0, & \text{otherwise}
\end{cases}$ is Riemann integrable.
My attempt:
To prove this, I need to show that there exists a partition $P$ such that the difference between the upper and lower Darboux sums (denoted $\mathcal U(P,f)$ and $\mathcal L(P,f)$ respectively) is less than any $\epsilon>0$.
I have the following formulae:


*

*$\mathcal U(P,f)=\sum^n_{i=1} M_i\Delta x_i$

*$\mathcal L(P,f)=\sum^n_{i=1} m_i\Delta x_i$

*$m_i= \inf\{f(x):x_{i-1} \le x \le x_i\}$

*$M_i=\sup\{f(x):x_{i-1} \le x \le x_i\}$

*$\Delta x_i= x_i - x_{i-1}$
However, to begin this computations I need a partition $P$. How should one go about determining this?
Any help would be greatly appreciated.
 A: pick arbitrary $x>0$ we know that there is $n \in \mathbb{N}$ s.t $\frac{1}{n}< x $ because $\lim_{n \rightarrow \infty} \frac{1}{n} = 0$ . Now we know that there are atmost finite number of discontinuities on $[\frac{1}{n}, 1]$ hence your function is integrable on $[\frac{1}{n},1]$ Since this holds for arbitrary $x$ we can say that function is integrable on interval $[x,1]$ for any $x>0$.Hence it is Riemann Integrable on $[0,1]$ using  following theorem.

$f : [a, b] \rightarrow \mathbb{R}$ is bounded, and $f$ is integrable on $[c, b]$ for all  $ c \in$
$(a, b)$, then f is integrable on $[a, b]$.

infact you can calculate value integral of function by proving following
$$\int_{0}^1 f  = \lim_{n \rightarrow \infty} \sum_{k=1}^{n} \int_{\frac{1}{k+1}}^{\frac{1}{k}} f = 0$$
can you prove the threorem and above statement?
A: I guess you want a elementary detailed proof.
Fix $\epsilon>0$, there exists $n_0\in\Bbb N$ such that $\frac{1}{n_0}<\epsilon/2$. Then we can split $[0,1]$ into $[0,\frac{1}{n_0}]$ and $[\frac{1}{n_0},1]$. Notice that $[\frac{1}{n_0},1]$ contains only finitely many $\frac{1}{n}$, therefore $f$ has only finitely many discontinuous points on $[\frac{1}{n_0},1]$. Thus $f$ is integrable on $[\frac{1}{n_0},1]$(why?). Then we can choose a partition $P:x_0,x_1,...x_N$ of $[\frac{1}{n_0},1]$ such $U(P,f)-L(P,f)<\epsilon/2$. 
We consider $Q=P\cup\{0\}$. Let $Q:y_0,...y_{N+1}$.
Notice that $y_1=x_0,y_2=x_1,...y_{N+1}=x_N$. 
Thus 
$U(Q,f)-L(Q,f)$
$=(M_1-m_1)\Delta y_1+\sum_{i=2}^{N+1}(M_i-m_i)\Delta y_i$
$=(M_1-m_1)\Delta y_1+\sum_{i=1}^{N}(M_i-m_i)\Delta x_i$
$<(1-0)(\frac{1}{n_0}-0)+U(P,f)-L(P,f)$
$=\frac{1}{n_0}+\epsilon/2$
$<\epsilon/2+\epsilon/2$
