Floor function limit I need help to calculate this limit $$\lim_{n\to\infty}{\dfrac{1}{n}\sum_{k=1}^{n}{\left(\dfrac{n}{k}-\left\lfloor\dfrac{n}{k}\right\rfloor\right)}}$$ I tried using Riemann sums but I don’t get anything useful
 A: By denoting the fractional part of $x$ through $\{x\}$, Riemann sums give that the wanted limit equals
$$ \int_{0}^{1}\left\{\frac{1}{x}\right\}\,dx =\sum_{n\geq 1}\int_{\frac{1}{n+1}}^{\frac{1}{n}}\left(\frac{1}{x}-n\right)\,dx=\sum_{n\geq 1}\left[\log\left(1+\frac{1}{n}\right)-\frac{1}{n+1}\right]=\color{red}{1-\gamma}$$
since $\sum_{n\geq 1}\left[\frac{1}{n}-\log\left(1+\frac{1}{n}\right)\right]=\gamma$ and $\sum_{n\geq 1}\frac{1}{n(n+1)}=1$.
A: We can rewrite the expression in terms of two well studied sequences/functions:
$$\frac1n \sum_{k=1}^n \left(\frac{n}{k} - \left\lfloor \frac{n}{k}\right\rfloor\right) = H_n - \frac1n D(n)$$ 
where $H_n$ is the harmonic number and $D(n)$ is the divisor summatory function.
For large $n$, we know
$$H_n = \log(n) + \gamma + O(n^{-1})\quad\text{ and }\quad
D(n) = n\log(n) + n(2\gamma - 1) + O(n^{1/2})$$
From this, we can deduce
$$H_n - \frac1n D(n) = \log(n) + \gamma - \frac1n(n\log n + n(2\gamma-1)) + O(n^{-1/2}) = 1 - \gamma + O(n^{-1/2})$$
This means the limit is $1 - \gamma$. I have no idea how to derive this from first principle.
A: The Riemann sum asks us to evaluate 
$\int_{0}^{1}{\frac{1}{x}-\lfloor \frac{1}{x}\rfloor dx}=\lim _{N\to 
\infty }\int_{1}^{N}{\frac{1}{x}-\frac{\lfloor x\rfloor }{x^{2}}dx}$.
Abel summation tells us that $\int_{1}^{N}{A(u)f'(u)du=\sum_{n=1}^{N}{a_{n}f(n)-A(N)f(N)}}$\, where $A(N)=\sum_{n=1}^{N}{a_{n}}$.
Set $f^{'}(x)=-\frac{1}{x^{2}}$, $f(x)=\frac{1}{x}$, $a_{n}=1, A(N)=N$ to get 
$\int_{1}^{N}{\frac{\lfloor x\rfloor 
}{x^{2}}dx}=\sum_{n=1}^{N}{\frac{1}{n}}-1$ and therefore $\lim _{N\to \infty }\int_{1}^{N}{\frac{1}{x}-\frac{\lfloor x\rfloor 
}{x^{2}}dx}=\lim _{N\to \infty }\ln N-(\ln N+\gamma )+1=1-\gamma $.
