Prove that $f$ is Riemann-integrable on $[a,b]$ Assume that $\{r_n\}$ is an index of rational numbers in the interval $[a,b]$ and $\{v_n\}$ is a sequence of non-zero real numbers which converges to $0$.    
Define $f:[a,b] \to \mathbb R$ this way :
If $x=r_n$ ,  $f(x)=v_n$
If $x \notin \mathbb Q \cap [a,b]$ , $f(x)=0$  

Prove that $f$ is Riemann-integrable on $[a,b]$.

My try :  
I observed that $f$ is discontinuous on each interval and is not monotonic on any interval. That makes it hard to prove the statement above. I don't know what to do next...
 A: Lemma (not hard to prove): If $f_1,f_2,\dots$ are Riemann integrable (RI) on $[a,b],$ and $f_n\to f$ uniformly on $[a,b],$ then $f$ is RI on $[a,b].$
In our problem, we have
$$f(x) = \sum_{k=1}^{\infty}v_k\chi_{\{r_k\}}(x).$$
Now each summand above is RI, hence so is $S_n(x) =\sum_{k=1}^{n}v_k\chi_{\{r_k\}}(x)$ for any finite $n.$ For any $x\in [a,b],$ we have
$$|f(x) - S_n(x)| =  \sum_{k=n+1}^{\infty}v_k\chi_{\{r_k\}}(x) \le \sup \{v_{n+1}, v_{n+2}, \dots \}.$$
The supremum on the right $\to 0$ by hypothesis. Hence $S_n \to f$ uniformly on $[a,b],$ and we're done by the lemma.
A: Let $x$ not in $Q\cap [0,1]$, suppose that $f$ is not continuous at $x$, there exists $c>0$ and a sequence $x_m$ such that $lim_nx_m=x$ and$|f(x_m)|>c$. 
We have $x_n\in Q\cap [a,b]$, and $f(x_m)=v_{g(m)}$ where $x_m=r_{g(m)}$. The sequence of $x_m$ contains infinite distinct terms. This implies that for every $M>0$ there exists  $L$ such that $m>L$ implies that $g(m)>M$. Since $lim_nv_n=0$, there exists $M_c$ such that $n>M_c, |v_n|<c$, we can choose $L_c$ such that $m>L_c$ implies that $g(m)>M_c$.  We deduce that $m>L_c$ implies that $|f(x_m)|=|v_{g(m)}|<c$. Contradiction.
The Lebesgue integrability condition implies that $f$ is Riemann integrable.
A: I think in this way it should work:
Consider for the sake of simplicity $v_n >0$ for each $n \in \mathbb{N}$. Let $ 1 > \epsilon >0$ By definition there exists $n_m \in \mathbb{N}$ such that $v_n < \epsilon$ for each $n \ge n_m$.
Now observe that one can assume that $ a = r_1 < r_2 < . . . < r_{n_m} = b$. Take $\delta$ to be $\epsilon\min\{ | r_i - r_j |\}/2$ Consider the partition $P =r_1< r_1 + \delta/2 < r_2 . . . r_{n_m - 1} + \frac{\delta}{2^{n_m - 1}} < r_{n_m} $ which now i rename $ x_{1}^0 < x_{1}^1 < . . . < x_{n_m}^0$. We have that $U(P) = \sum_{i=1}^{n_m-1} v_i ( x_{i}^1 - x_{i}^0) + \sum_{i=2}^{n_m} \sup_{[ x_{i-1}^1, x_{i}^0]}(f(x)) (x_{i}^0 - x_{i-1}^1)$ Now you can extimate this upper riemann sum observing:


*

*our choose of $n_m$ gives $\sup_{[ x_{i-1}^1, x_{i}^0]}(f(x)) < \epsilon$

*our choose of the partition gives $\sum_{i=1}^{n_m-1} v_i ( x_{i}^1 - x_{i}^0) \le \max\{v_1, . . .,v_{n_m}\}\ \epsilon$


Thus you get $U(P) \le \max\{v_1, . . .,v_{n_m}\}\ \epsilon + \epsilon (b - a)$ and you can conclude, because a convergent sequence of real numbers is bounded, that $U(P) \rightarrow 0$, thus the claim since it's obvious that $L(P) \ge 0$ (I supposed $v_n \ge 0$, otherwise you have to do the same thing for lower sums).
