I've proven Thomae's function $$ f(x)=\begin{cases}\frac{1}{q},&\text{if }x=\frac{p}{q}\in\mathbb{Q}\text{ in lowest terms, }x\neq0;\\0,&\text{ otherwise}.\end{cases} $$ is Riemann integrable and integrates to zero. Consider the slight modification $$ f(x)=\begin{cases}\frac{1}{p},&\text{if }x=\frac{p}{q}\in\mathbb{Q}\text{ in lowest terms, }x\neq0;\\0,&\text{ otherwise}.\end{cases} $$ I've been trying to prove that this function is Riemann (Darboux) integrable, say, on $[0,1]$, but haven't been able to. Clearly any lower sum $L(f,P)$ for this function is zero, so for some $\epsilon>0$ I've been trying to find a partition $P$ such that $U(f,P)<\epsilon$. Here's the difficulty from what I can see: You have to be particularly careful with how you construct such $P$ on the interval $[0,1/2]$. We have $f(1/n)=1$ for all $n\in\mathbb{N}$, so for each interval $[a_{i-1},a_i]$ in $P$ that contains some $\frac{1}{n}$, we have $\sup_{x\in[a_{i-1},a_i]}f(x)=1$, i.e., you have to control the size of these intervals, or else you have no hope of $U(f,P)<\epsilon$. For the remaining intervals, you have to worry about the fractions $\frac{2}{n}$ in lowest terms, etc. It seems like a complex balancing act, and the smaller the $\epsilon$, the more specific you have to be.
I thought maybe taking the Darboux approach might not be a good way to do it, maybe I should be using Riemann sums. This allows me to choose the points in each interval to evaluate on, but, as far as I know, the corresponding theorem for Riemann sums is that it has to work for any choice of points in an interval of $P$, so this doesn't help much.
Unlike other analogs, e.g. here, there isn't a way to write this function in terms of Thomae's function. Can you give me some ideas for how to figure this out?