Prove a piecewise function is integrable Let the function:

$$
f(x) = \begin{cases} 1 &\mbox{if } x = \tfrac{1}{n}, n\in\mathbb{N} \\
0 & \text{otherwise} \end{cases} $$
Show that $f(x)$ integrable and evaluate $$\int_0^1 f(x)\,dx$$

So we want that for every $\varepsilon > 0$ there is a $\delta > 0$ s.t. for every $\Pi = \{0 = x_0, \ldots, x_k = 1\}$ such that $\lambda(\Pi) < \delta$ we have that $\omega(f, \Pi) < \varepsilon$.
Let's define:
$$B = \{ i \ |\ \exists x\in\Delta x_i. f(x)=1\}$$
$$G = \{ i \ |\ \forall x\in\Delta x_i. f(x)=0\}$$
Now, 
$$\omega(f, \Pi) = \sum_i \omega(f, \Delta x_i)\Delta x_i = \sum_{i\in B} \omega(f, \Delta x_i)\Delta x_i + \sum_{i\in G} \omega(f, \Delta x_i)\Delta x_i = 0 + \sum_{i\in B} 1\cdot \Delta x_i \le \sum_{i\in B} \delta \le \delta $$
And if we choose $\delta < \varepsilon$ then we're done.
Is that right?
Note:
$$\lambda(\Pi) =  \max(\Delta x_1, \ldots, \Delta x_n)$$
$$\omega(f, \Delta x_i) = \sup_{\Delta x_i} f(x) - \inf_{\Delta x_i} f(x)$$
$$\omega(f, \Pi) = \sum_i \omega(f, \Delta x_i) \Delta x_i$$

Given $\varepsilon > 0$, let $N$ be the smallest integer such that $1/N < \varepsilon/2$. For each $i \in \{2, 3, \ldots, N - 1\}$, let $B_i = [1/i - \delta, 1/i + \delta]$, and for $i = 1$, let $B_1 = [1 - \delta, 1]$, where $\delta = \frac{1}{2N^2}$. That is, $B_i$ is the closed neighborhood of $\frac{1}{i}$ with radius $\delta$ for $i \neq 1$. Set
$$x_1 = \frac{1}{N}, x_2 = \frac{1}{N - 1} - \delta, x_3 = \frac{1}{N - 1} + \delta, \ldots, x_{2N - 4} = \frac{1}{2} - \delta, x_{2N - 3} = \frac{1}{2} + \delta, x_{2N - 2} = 1 - \delta.$$
Let $\Pi = \{0, x_1, \ldots, x_{2N - 3}, x_{2N - 2}, 1\}$, in this way, 
$$\omega(f, \Pi) = 1 \times \frac{1}{N} + \sum_{i = 2}^{N - 1}1 \times 2\delta + \delta= \frac{1}{N} + (2N - 3)\delta < \frac{1}{N} + \frac{1}{N} < \varepsilon.$$
Therefore $f$ is Riemann-integrable.
