TITLE: computing an integration with a floor function
QUESTION [5 upvotes]: I am trying to compute 
$$\int_0^1 \left(\frac{1}{x} -  \biggl\lfloor \frac{1}{x}\biggr\rfloor\right) dx$$ 
with no success.
Any hints?

REPLY [4 votes]: $$\int_0^1 \left(\frac{1}{x} - \left\lfloor \frac{1}{x}\right\rfloor\right) dx=\lim_{k\to +\infty}\int_{\frac{1}{k}}^1 \left(\frac{1}{x} - \left\lfloor \frac{1}{x}\right\rfloor\right) dx$$ 
Now to compute the other integral use the decomposition:
$$\int_{\frac{1}{k}}^1 \left(\frac{1}{x} - \left\lfloor \frac{1}{x}\right\rfloor\right) dx=\sum_{i=1}^{k-1} \int_{\frac{1}{i+1}}^{\frac{1}{i}}\left(\frac{1}{x} -i\right)dx=\sum_{i=1}^{k-1}\left[\ln(x)-ix\right]_{\frac{1}{i+1}}^{\frac{1}{i}}$$
and you can compute this sum and determine the limit, After computation you obtain:

$$\sum_{i=1}^{k-1}\left[\ln(x)-ix\right]_{\frac{1}{i+1}}^{\frac{1}{i}}=\ln(k)-\sum_{i=2}^{k}\frac{1}{i}$$

and this gives you:

$$\int_0^1 \left(\frac{1}{x} - \left\lfloor \frac{1}{x}\right\rfloor\right) dx=1-\gamma$$

with $\gamma$ denotes Euler–Mascheroni constant