This question is actually from a programming question that a formula is required to compute maths faster. (Please note that computer frequently rounds down to the nearest integer, thus the floor function is involved even if it is not explicitly stated in the question in the link)
So here is the formula I needed for the question:
For any positive integer $n$, Let $k=\lfloor\sqrt{n}\rfloor$. Prove that: $$ \sum_{i=1}^n \bigg\lfloor\frac{n}{i}\bigg\rfloor = 2\sum_{i=1}^k \bigg\lfloor\frac{n}{i}\bigg\rfloor - k^2 $$ I've verified this for $n$ up to $10000$ (by a computer) and got a (very) informal proof (which relies heavily on not-so-obvious assumptions). However, I wasn't able to obtain even a semi-informal proof, thus I've asked for help here.
P.S. I would like to have someone format the formula. I don't know how to do it. Thank you.
Edit: Thank you avraham for formatting that. Formatting a summation is much easier than I've expected!