How to prove that $\lim\limits_{n\rightarrow \infty} \frac{1}{n^2}\sum\limits_{k=1}^{n}(n \bmod k)=1-\frac{\pi^2}{12}$?
Using division with remainder, if $n=q_kk+r_k$ s.t. $0\leq r_k < k$, then $r_k=n \pmod{k}$. Also $q_k=\left \lfloor \frac{n}{k} \right \rfloor$ and $$r_k=n-k\left \lfloor \frac{n}{k} \right \rfloor$$ Then $$\frac{1}{n^2}\sum_{k=1}^{n}(n \bmod k)= \frac{1}{n^2}\sum_{k=1}^{n}r_k= \frac{1}{n^2}\sum_{k=1}^{n}\left(n-k\left \lfloor \frac{n}{k} \right \rfloor\right)=\\ 1-\frac{1}{n}\sum_{k=1}^{n}\frac{k}{n}\left \lfloor \frac{n}{k} \right \rfloor \to \color{red}{1-\int\limits_{0}^{1}x\left \lfloor \frac{1}{x} \right \rfloor dx}, n\to\infty \tag{1}$$
Now $$\int\limits_{0}^{1}x\left \lfloor \frac{1}{x} \right \rfloor dx= \int\limits_{0}^{\frac{1}{2}}x\left \lfloor \frac{1}{x} \right \rfloor dx + \int\limits_{\frac{1}{2}}^{1} xdx= \int\limits_{0}^{\frac{1}{3}}x\left \lfloor \frac{1}{x} \right \rfloor dx + \int\limits_{\frac{1}{3}}^{\frac{1}{2}} 2xdx + \int\limits_{\frac{1}{2}}^{1} xdx=\\ \int\limits_{0}^{\frac{1}{4}}x\left \lfloor \frac{1}{x} \right \rfloor dx + \int\limits_{\frac{1}{4}}^{\frac{1}{3}} 3xdx + \int\limits_{\frac{1}{3}}^{\frac{1}{2}} 2xdx + \int\limits_{\frac{1}{2}}^{1} xdx=\\ \sum_{n=1}n \int\limits_{\frac{1}{n+1}}^{\frac{1}{n}} xdx= \sum_{n=1}\frac{n}{2} \left(\frac{1}{n^2}-\frac{1}{(n+1)^2}\right)= \frac{1}{2}\sum_{n=1}\frac{2n+1}{n(n+1)^2}=\\ \frac{1}{2}\sum_{n=1}\frac{n+n+1}{n(n+1)^2}= \frac{1}{2}\sum_{n=1}\left(\frac{1}{(n+1)^2}+\frac{1}{n(n+1)}\right)=\\ \frac{1}{2}\sum_{n=1}\left(\frac{1}{(n+1)^2}+\frac{1}{n}-\frac{1}{n+1}\right)=\\ \color{red}{\frac{1}{2}\sum_{n=1}\frac{1}{(n+1)^2}}+\color{blue}{\frac{1}{2}\sum_{n=1}\left(\frac{1}{n}-\frac{1}{n+1}\right)}=\\ \color{red}{\frac{1}{2}\sum_{n=1}\frac{1}{n^2}-\frac{1}{2}}+\color{blue}{\frac{1}{2}}=\frac{1}{2} \cdot \frac{\pi^2}{6}$$ which indeed is $\frac{\pi^2}{12}$, because of this.