How can I show that this function is riemann integrable? Let $I = [0,1],$ and $f : I\times I \to \mathbb{R}$ defined as follows:
$$f(x,y) = \frac{1}{q} ~~\text{if}~~ x = \frac{p}{q}, y \in \mathbb{Q},$$
$$f(x,y) = 0 ~~\text{otherwise}$$
How can I show that this function is integrable?
I am trying to follow one idea used to this similar function only considered on $[0,1]$ defined the same way. Given $\epsilon > 0,$ in that case I took $F = \{x \in [0,1] : f(x) \ge \epsilon\},$ then this set is finite and then I could choose one partition such that the sum os the volumes of intervals that intercept $F$ is less then $\epsilon$, in this way I can separate the upper sum in cases that I can control.
So my question is, on the previous argument, to choose the intervals of that way, aren't implying that $F$ has null measure? Or not? Why can I take on that form? 
For the function that I stated at the beginning, how can I show that it is integrable?
Thanks a lot!
Please, don't mark to close the question, if there are any questions, or suggestions to improve the problem, I am glad in improve.
 A: If $n$ is a positive integer, the set $F_{n} \subset [0, 1] \times [0, 1]$ on which $f(x, y) > \frac{1}{n}$ is contained in the finite union of intervals
$$
J_{n} := \bigcup_{j=1}^{n} \bigcup_{i=0}^{j} \{\tfrac{i}{j}\} \times [0, 1].
$$
Particularly,


*

*The closed set $J_{n}$ has Lebesgue measure (and Jordan content) zero.

*The function $f$ is continuous on the complement $X := [0, 1] \times [0, 1] \setminus \bigcup_{n=1}^{\infty} J_{n}$ (since $f$ vanishes on $X$, and is bounded above by $\frac{1}{n}$ on the open neighborhood $[0, 1] \times [0, 1] \setminus J_{n} \supset X$).
A: The standard proof of measure zero goes as follows:
Let $$f(x)=\cases{1/q&if $x=p/q$ in lowest terms\cr 0& otherwise\cr}$$
Then $f$ is discontinuous at $r$ iff $r\in\mathbb Q$.
Proof: If $\displaystyle r={p\over q}$, then $\displaystyle f(r)={1\over q}$. Choose $s_1,s_2,\ldots $ converging to $r$ such that each $s_i$ is irrational. Then $$\lim_{n\to\infty} s_n = \lim_{n\to \infty} 0 = 0 \not=f(r).$$
Hence $f$ is not continuous at $r$.
Now suppose $r\not\in\mathbb Q$, and pick $\epsilon>0$. Let $\displaystyle N>{1\over\epsilon}$ be an integer, and $s_1,s_2,\ldots, s_k$ be the rational numbers within $1$ of $r$, which have a denominator less than or equal to $N$. Pick 
$$\delta = \min_{1 \le i \le k} | s_i - r |.$$
$\delta>0$, because it is the minimum of finitely many positive real numbers.
Also, if $|x-r|<\delta$, then either $x$ is irrational (in which case $f(x)=0$), or $x=p/q$ and $q>N$ (in which case $\displaystyle f(x)={1\over q}<{1\over N} =\epsilon$).
In either case, if $|x-r| < \delta$, $|f(x)-f(r)|<\epsilon$. Since $\epsilon$ was arbitrary, $f$ is continuous at $r$. QED. (Mutatis Mutandis ... Modify where needed for your problem.)
