It's supposed to return the sum of number of divisors of numbers from 1 to N. If you have better approach than this then please let me know.

I really don't understand it. Why stop at the square root and why, after that, double the result then subtract the square of the square root?

Code: Select all

```
long long summation_of_divs_count(long long n)
{
long long sum = 0, root = sqrt(double(n));
for (int i = 1; i <= root; ++i)
sum += (n / i);
return ((sum + sum) - (root * root));
}
```