Question: Let $f: [0,1] \rightarrow \mathbb{ R}$ be determined by:

$f(x) = 0 $when $x$ is irrational

$\frac{(-1)^p}{q}$ when $x$ is rational (and in reduced form $\frac{p}{q}$)

Show that $f$ is Riemann integrable on $ [0,1]$and that the integral equals $0$. 

Any help would be much appreciated! Thank you!

Answer: 
Let $\epsilon >0$. Pick some $N$ such that $\frac{1}{N} < \frac{\epsilon}{2}$.

Show first that there are only finitely many fractions $\frac{p\_1}{q\_1},..., \frac{p\_M}{q\_M}$ such that $q\_M<N$.

Now, pick any partition $0=x\_0<x\_1<\cdots<x\_{k-1}<x\_k=1$ with $\| P \| < \frac{\epsilon}{2M}$.

Then 
$$
\left| \sum\_{i}f(t\_i)\cdot(x\_{i+1} - x\_i) \right| \leq \sum\_{i}\left| f(t\_i)\cdot(x\_{i+1} - x\_i) \right| \\
=\sum\_{|f(t\_i)|<\frac{\epsilon}{2}}\left| f(t\_i)\cdot(x\_{i+1} - x\_i) \right| +\sum\_{|f(t\_i)|\geq\frac{\epsilon}{2}}\left| f(t\_i)\cdot(x\_{i+1} - x\_i) \right| \\
\leq\sum\_{|f(t\_i)|<\frac{\epsilon}{2}}\frac{\epsilon}{2}\left| (x\_{i+1} - x\_i) \right| +\sum\_{|f(t\_i)|\geq\frac{\epsilon}{2}}\left| (x\_{i+1} - x\_i) \right| 
\\
\frac{\epsilon}{2} +\sum\_{|f(t\_i)|\geq\frac{\epsilon}{2}} \| P \|\leq \frac{\epsilon}{2}+M \| P\|
$$
Well the function is continous everywhere except for rational points. Thus the set of discontinuities is of (Lebesgue) measure $0$ so $f$ is Riemann integrable.

Now you can calculate the integral directly from the definition. Pick any partition $0=x\_0<x\_1<\cdots<x\_{k-1}<x\_k=1$. For any $i$ pick $t\_i$ an irrational such that $x\_i < t\_i < x\_{i+1}$. Then 

$$\sum\_{i=1}^k f(t\_i)\cdot(x\_{i+1} - x\_i)=\sum\_{i=1}^k0\cdot(x\_{i+1}-x\_i)=0$$

Now you can go to the limit with this kind of partitions (remember that irrationals are dense) and since that limit has to be the Riemann integral (since the function is integrable) then the integral is $0$.

Note that values of $f(x)$ for rational $x$ doesn't matter at all. The integral will always be $0$ as long as the set of discontinuities of $f$ is of measure $0$ and $f=0$ elsewhere.