I learnt that
$$\lim_{n\rightarrow \infty} \frac{1}{n^2}\sum_{k=1}^{n}(n \bmod k)=1-\frac{\pi^2}{12}$$
where $ (n{\bmod {k}})$ is the remainder upon division of $n$ by $k$. However, I am not sure how to arrive at this equation.
I understand that
$$\infty \bmod 1 = 0$$ But I don't see how infinity can mod anything else. For example, $$\infty \bmod 2 = ~?$$ $$\infty \bmod 3 = ~?$$ I am thinking about either converting the limit into an integral, but I haven't figured out how. Any hints on how to evaluate the limit?
I also found a more general form of the limit (not sure if this will help with the original question): For $a>0,~b\geq1$, $$\lim_{n\rightarrow \infty} \frac{1}{n^2}\sum_{k=1}^{an}(an \bmod bk)=a^2\left(1-\frac{\pi^2}{12b}\right)$$