Let $f:\mathbb{R}\rightarrow\mathbb{R}$ be defined by setting $f(x)=1/q$ if $x=p/q$, where $p$ and $q$ are positive integers with no common factor, and $f(x)=0$ otherwise. Show that $f$ is integrable over $[0,1]$.
I'm using the Darboux definition of integration, so I want to prove that for any $\epsilon>0$ there exists a partition $P$ of $[0,1]$ such that $U(f,P)-L(f,P)<\epsilon$. Equivalently, there exists a partition $P$ of $[0,1]$ such that $$\sum_Rv(R)(M_R(f)-m_R(f)) < \epsilon$$ where $M_R(f)$ is the supremum of $f$ inside interval $R$, $m_R(f)$ is the infimum of $f$ inside interval $R$, and $R$ ranges over all intervals in the partition.
So I tried taking $P=[0,\dfrac1n,\dfrac2n,\ldots,1]$. The sum in question becomes $$\dfrac1n\sum_{i=0}^{n-1}(M_{[\frac{i}{n},\frac{i+1}{n}]}(f)-m_{[\frac{i}{n},\frac{i+1}{n}]}(f))$$
I know that $m_{[\frac{i}{n},\frac{i+1}{n}]}(f)=0$, because in the interval $[\dfrac{i}{n},\dfrac{i+1}{n}]$ there is an irrational number, so the sum reduces to $$\dfrac1n\sum_{i=0}^{n-1}M_{[\frac{i}{n},\frac{i+1}{n}]}(f)$$
I don't really know anything about the fraction with lowest denominator inside $[\dfrac{i}{n},\dfrac{i+1}{n}]$. How can I prove that this sum goes to $0$ as $n\rightarrow\infty$?