Compute $\int_{0}^{1}\left[\frac{2}{x}\right]-2\left[\frac{1}{x}\right]dx$ The question is to find
$$\int_{0}^{1}\left(\left[\dfrac{2}{x}\right]-2\left[\dfrac{1}{x}\right]\right)dx,$$
where $[x]$ is the largest integer no greater than $x$, such as $[2.1]=2, \;[2.7]=2,\; [-0.1]=-1.$
Is there any nice method to solve this integral,Thank you everyone.

Some of my thoughts: I have if $a\in(0,1]$, then
$$\int_{0}^{1}\left[\dfrac{a}{x}\right]-a\left[\dfrac{1}{x}\right]dx=a\ln{a}.$$
What about $a>1$,
$$\int_{0}^{1}\left[\dfrac{a}{x}\right]-a\left[\dfrac{1}{x}\right]dx=?$$
and  $$\int_{0}^{1}\left(\left[\dfrac{2}{x}\right]-2\left[\dfrac{1}{x}\right]\right)^{2}dx=?$$
becasue I have
$$\int_{0}^{1}\left(\dfrac{1}{x}-\left[\dfrac{1}{x}\right]\right)^2=-1-\gamma+\ln{(2\pi)}$$

You just have to figure out where the integrand is nonzero.  In this case, the integrand really takes the value
$$\left\lfloor \frac{2}{x} \right\rfloor - 2\left \lfloor \frac{1}{x} \right\rfloor = \begin{cases} \\0 & x \in \left [ \frac{2}{2 n+1},\frac{2}{2 n}\right )\\ 1 & x \in \left [ \frac{2}{2 n},\frac{2}{2 n-1}\right ) \end{cases}$$
for $n \ge 1$ and $x \in [0,1]$.  Here is a plot generated in Mathematica:

Thus, the integral is just a sum of the interval lengths over which the integrand has the value of $1$:
$$\begin{align}\int_0^1 dx \, \left ( \left\lfloor \frac{2}{x} \right\rfloor - 2\left \lfloor \frac{1}{x} \right\rfloor \right ) &= \frac{2}{3} - \frac{2}{4} + \frac{2}{5} - \frac{2}{6} + \ldots \\ &= 2 \left [ \sum_{k=1}^{\infty} \frac{(-1)^{k+1}}{k} - \frac12 \right ]\\ &= 2 \log{2} - 1\end{align}$$
