Is there any direct formula or algorithm better than the brute force (O(n) algorithm by iterating from 1 to n) way to calculate the sum
\begin{equation} S = \sum\limits_{i=1}^n [{\frac{n}{i}}] \end{equation}
where [x] denotes the integral part of x?
I tried out calculating the sum by considering i's that are factors of n. But that does not seem to give the correct answer. Any help in any form is welcomed.
Please point out the mistakes in tags and formatting of the question too, since I am a beginner here.