Why $f(x)$ is Riemann integrable? If somebody can explain to me why the following function is Riemann Integrable on $[0,1]$ and how to find $\int_0^1 f(x)~dx$
$$f(x)= \begin{cases}1 &\text{ if }  x=0\\
0 &\text{ if } x \in [0,1] \setminus \Bbb{Q}, \\
\frac 1n &\text{ if } x=\frac mn \in [0,1] \cap \Bbb{Q} \text{ with } \gcd(n,m)=1\end{cases}
$$
 A: Assuming that you mean
$$f(x)=\begin{cases}1,&x=0, \\ 0, & x\in [0,1]\setminus\mathbb Q, \\ \frac{1}{n},&x=\frac{m}{n}\in [0,1]\cap\mathbb Q,~\operatorname{gcd}(m,n)=1\\ \end{cases}$$
We first note that $0\leq f\leq 1$ and therefor 
$$0\leq\int\limits_{0^*}^{1}\!f(x)\,\mathrm{d}x \leq \int\limits_{0}^{1^*}\!f(x)\,\mathrm{d}x.$$
Let $\varepsilon>0$, then the set
$M:=\{\frac{p}{q}~|~1\leq q\leq \frac{1}{\varepsilon},~0\leq p\leq q\}$ is finite and we can define a step function
$$\psi:[0,1]\rightarrow\mathbb R,~\psi(x)=\begin{cases} f(x),&x\in M \\ \varepsilon,&x\notin M\end{cases}.$$
It is obvious that we have $f\leq\psi$ and therefor
$\int\limits_{0}^{1^*}\!f(x)\,\mathrm{d}x\leq\int\limits_{0}^{1}\!\psi(x)\,\mathrm{d}x=\varepsilon$. This yields that $f$ is riemann-integrable with $$\int\limits_{0}^{1}\!f(x)\,\mathrm{d}x=0.$$
A: For a slightly more high-powered answer, this function is continuous everywhere except the rationals, so it meets the Lebesgue criterion for Riemann integrability: A bounded function on a compact interval is Riemann integrable if and only if it is continuous except on a set of measure zero.
