TITLE: Calculating the Lebesgue and Riemann integrals
QUESTION [5 upvotes]: Given $$f(x) = 
\begin{cases}
 \frac{1}{q} & \text{if}~~ x =  \frac{p}{q},(p,q)=1 ~,p\leqslant q, \text{is rational},~ 0\leqslant x \leqslant 1 \\
 0 & \text{if}~~ x ~~\text{is irrrational}, 0\leqslant x \leqslant 1
 \end{cases}
$$ 
I want to find both the Lebesgue and the Riemann integral of $f(x)$. 
this is my attempt.
For the Lebesgue integral, I define $f(x) = 1\cdot 1_{\mathbf{Q}\cap [0,1]} +0\cdot 1_{[0,1]\setminus \mathbf{Q}}$. Then 
$$\begin{align*}
\int_0^1 f(x)dx & = 1\cdot \mu(\mathbf{Q}\cap [0,1]) + 0 \\
& = 0 .
\end{align*}$$ where $\mu$ is the Lebesgue measure.
I think the Riemann integral should also be $0$. Here is what I've done.
Let $P$ be a partition of $[0,1]$. Then since the irrationals are dense in $[0,1]$, every subinterval of $P$ will have a point where $f(x) = 0$. So the lower sum, $L(f,P) = 0.$ Thus $$\underline{\int_0^1} f(x) dx = \sup L(f,P) = 0.$$ 
Going with my guess, $\overline{\int_0^1} f(x)dx$ should also be 0$, but I don't know how to get it. so I want help with it. Also, is what I've done above alright?

REPLY [2 votes]: Quick hint: For any $\varepsilon>0$, there are only a finite number of point $x\in[0,1]$ with $f(x)>\varepsilon$. That should let you get at the upper Riemann sum.
More precisely, make a step function whose value is $\varepsilon$ in most of $[0,1]$, but takes on bigger values near those points where $f(x)>\varepsilon$. It can take the bigger values in intervals as short as you wish, and since there are only a finite number of points to take care of, this should get you there.