Efficient calculation of sum over divisor sum (mod p)

366 Views Asked by At

Suppose you want to exactly compute the following sum (i.e. not approximate/estimate it):

$$ \sum_{i=1}^n \sigma_1(i) \mod p $$

Here, $\sigma_1(i)$ is the sum of all positive divisors of $i$, and $p$ is a prime number.

Is there a known way to make this calculation more efficient than computing each $\sigma_1(i)$ individually and summing them all up?

It should be noted that $\sigma_1$ is a multiplicative function (but not completely). Maybe this fact can be taken advantage of?

Alternatively, if we knew how to quickly find some $m < n$ (ideally, as close to $n$ as possible) so that the partial sum $\sum_{i=1}^m \sigma_1(i)$ equals zero or any other constant number (modulo $p$), then it would be sufficient to compute the sum starting from $m+1$, i.e. $\sum_{i=m+1}^n \sigma_1(i)$.

1

There are 1 best solutions below

1
On BEST ANSWER

Slightly more efficient than calculating each $\sigma_1(i)$ is to note that any value m will occur $\left\lfloor\frac{n}{m}\right\rfloor$ times in the sum, so $$\sum_{i=1}^n \sigma_1(i) = \sum_{m=1}^n m \left\lfloor\frac{n}{m}\right\rfloor$$ but you will still have to sum n terms.