Is this the correct way to integrate this: $\int_0^5 (x^2+1) d \lfloor x \rfloor$ , where $\lfloor\cdot \rfloor$ is the greatest integer function? This Question was asked by my teacher and the solution he presented is this:
$$\int_0^5 (x^2+1) d \lfloor x \rfloor.$$
Before integrating the above, lets see this:
$\int_a^b f'(x)g(x) + g'(x)f(x)dx = \int_a^b \frac {d(f(x)g(x))}{dx} dx = f(b)g(b)-f(a)g(a)$ 
Let $f(x)=x^2 +1$ and $g(x)=\lfloor x \rfloor.\  f'(x)= 2x.$
$$\int_a^b f'(x)g(x) + g'(x)f(x)dx=f(b)g(b)-f(a)g(a)
\\\int_0^5 2x\lfloor x \rfloor + \frac{d\lfloor x \rfloor}{dx} (x^2 +1)dx=f(5)g(5)-f(0)g(0)
\\\int_0^5 2x\lfloor x \rfloor dx + \int_0^5 (x^2 +1)d\lfloor x \rfloor=130$$
Now, $\int_0^5 2x\lfloor x \rfloor dx = 70\ .$ So $\int_0^5 (x^2 +1)d\lfloor x \rfloor$ comes out to be 60.
I dont understand how integration on $\lfloor x \rfloor$ is even possible and hence the solution seems pretty strange to me. Would love to know how this integration is possible in the first place? 
 A: As a Riemann–Stieltjes integral, we have that 
$$d \lfloor x \rfloor=\sum_{k\in\mathbb{Z}}\delta(x-k)dx$$
where $\delta(x)$ is the Dirac delta function.
Hence 
$$\int_a^b f(x)d \lfloor x \rfloor=\sum_{k\in\mathbb{Z}\cap (a,b]}f(k).$$
A: It's "possible" because what you're computing is a Riemann–Stieltjes integral, i.e. $\int_a^b fdg$ is identified with $f(b)g(b)-f(a)g(a)-\int_a^b gdf$ if the latter is definable by narrower notions of integrability. There's nothing illegitimate or unfamiliar about this; but, as with summing infinite series, integration admits multiple definitions that vary in how many answers they define. (This definition achieves the same thing.) You'll see a very similar problem here, which you can solve the same way. Here are others.
A: Also the integral can be understood as a Lebesgue-Stieltjes integral, where $dg$ is a notation to represent the Lebesgue-Stieltjes measure $\mu_g$ generated by $g$.
For this case we have that $\mu_{\lfloor \cdot\rfloor}((a,b])=\lfloor b\rfloor-\lfloor a\rfloor$, what imply that $\mu_{\lfloor \cdot\rfloor}(\{a\})=\chi_{\Bbb Z}(a)$, and so
$$\int_{[0,n]} f(x)d\lfloor x\rfloor=\int_{\{0\}}f(x)d\lfloor x\rfloor+\sum_{k=0}^{n-1}\int_{(k,k+1]}f(x)d\lfloor x\rfloor=f(0)+\sum_{k=0}^{n-1} f(k+1)$$
