Let $h(x)= 0$ if $x$ is irrational and $1/q$ if $x=p/q$ where $p,q$ are natural numbers such that $gcd(p,q)=1$.
Show that the function is Riemann integrable.
The first part of the proof says: Let $\epsilon>0$ let $N\in \mathbb{N}$ such that $\frac{1}{N}<\frac{\epsilon}{2}$, then the number of $x's$ such that $h(x)>\frac{1}{N}$ are at most $N^2$.
Then for any partition $P$ of $[0,1]$ there are at most $2N$ intervals containing some $x$ such that $h(x)>\frac{1}{N}$.
My question is, how do you prove the statement in bold? and what's the intuition for it? Lastly, when would I use such a method to show a function is integrable?