Solution (source code)

= Solution

For a nondecreasing function, the endpoint bounds show it is bounded. On the uniform partition into $N$ intervals, its <Darboux sums> satisfy
$$
U-L=\frac1N\sum_{j=1}^N\left[f\left(\frac jN\right)-f\left(\frac{j-1}N\right)\right]
=\frac{f(1)-f(0)}N\longrightarrow0.
$$
For a nonincreasing function apply the same calculation to $-f$, or use $|f(1)-f(0)|/N$. Thus \b[every <monotone function> on $[0,1]$ is <Riemann integrable>].

For the unheaded rational-weight example, each summand is nonnegative, and increasing $x$ only adds indices. Hence its sum is nondecreasing and lies between zero and one, including the separately specified value at zero. It is a <left-continuous cumulative function of an atomic measure>.

If $q_j\in[0,1)$ and $q_j<x\leq1$, the index $j$ appears in the sum at $x$ but not at $q_j$. All other changes are nonnegative, so $f(x)-f(q_j)\geq2^{-j}$. This remains true for arbitrarily small positive $x-q_j$, proving discontinuity at $q_j$, including a right discontinuity at zero when that rational is encountered. Every interval of positive length contains such a rational in its interior. \b[The discontinuities are therefore dense], although \b[the function is <Riemann integrable>] by the monotone-function result just proved.

More concretely, truncate after the first $N$ weights. The resulting finite sum of step functions is integrable, and the uniform tail is at most $2^{-N}$. This also proves integrability and gives, if its value is desired,
$$
\boxed{\int_0^1 f(x)\,dx=\sum_{k=1}^\infty2^{-k}(1-q_k).}
$$
The integral formula follows by integrating the finite sums and using the uniform tail bound. Here “every interval” has the usual nondegenerate-interval meaning; a singleton is not being asserted to contain a discontinuity.