Limit question using limit as a sum 
$$\lim_{n\rightarrow \infty}\frac{1}{n}\bigg(\sum^{n}_{i=1}\left\lfloor \frac{2n}{i}\right\rfloor-2\left\lfloor\frac{n}{i}\right\rfloor \bigg)$$
Where $\lfloor x \rfloor$ is a floor function of $x$

Trial: using limit as a sum put $\displaystyle \frac{i}{n}=x$ and $\displaystyle \frac{1}{n}=dx$
$$\int^{1}_{0}\bigg(\left\lfloor\frac{2}{x}\right\rfloor -2\left\lfloor\frac{1}{x}\right\rfloor \bigg)dx$$
Let $\displaystyle \frac{1}{x}=t$ and $dx=-\frac{1}{t^2}dt$
So $\displaystyle \int^{1}_{0}\bigg(\lfloor 2t \rfloor - 2\lfloor t\rfloor \bigg)\cdot\frac{1}{t^2}dt$
Could some help me to solve it, Thanks
 A: Write $I$ for the integral and notice that
$$
I
= \int_{0}^{1} \left( \left\lfloor \frac{2}{x} \right\rfloor - 2 \left\lfloor \frac{1}{x} \right\rfloor \right) \, dx
= \int_{0}^{1} \left( \left\lfloor \frac{2}{x} \right\rfloor - \frac{2}{x} \right) \, dx + 2\int_{0}^{1} \left( \frac{1}{x} - \left\lfloor \frac{1}{x} \right\rfloor \right) \, dx
$$
(Without adding and subtracting the intermediate term $\frac{2}{x}$, you have $\infty-\infty$ indeterminate which is never good.) Now by the substitution $x \mapsto x/2$, the second integral becomes
$$ 2\int_{0}^{1} \left( \frac{1}{x} - \left\lfloor \frac{1}{x} \right\rfloor \right) \, dx
= \int_{0}^{2} \left( \frac{2}{x} - \left\lfloor \frac{2}{x} \right\rfloor \right) \, dx $$
Plugging this back, we find that
$$
I
= \int_{1}^{2} \left( \frac{2}{x} - \left\lfloor \frac{2}{x} \right\rfloor \right) \, dx
= \int_{1}^{2} \left( \frac{2}{x} - 1 \right) \, dx
= 2\log 2 - 1.
$$
A: To calculate the integral, we may consider the following partition of interval
$(0,1)$:
$$\frac{1}{2}\leq x<1\Rightarrow \left[\frac{1}{x} \right]=1, $$
$$\frac{1}{3}\leq x<\frac{1}{2}\Rightarrow \left[\frac{1}{x} \right]=2, $$
and so on.
Note also that for any $\alpha\in\mathbb{R}$, $[2\alpha]=[\alpha]+[\alpha+1/2] $.
