1

I was playing with the function $ f(n) = \sum_{i=1}^{n}{(n \mod i)} $. After looking at $ \frac{f(2n)}{f(n)}$ for some values it seemed quadratic, and I was wondering about the limit of $ \frac{f(n)}{n^2} $.

I tried to calculate that for big values. I was able to find a method to calculating it in $ O(\sqrt{n}) $, and for $n = 10^{19}$, $f(n) = 17753296657588678168165249620624323219$, and after giving the first few digits to wolfram alpha it seems like it's $1 - \frac{\zeta(2)}2$ (I found it with smaller values, and since it also matches for bigger values it feels likely it's correct).

Is that correct? How can I prove that?

Gabrielek
  • 1,898

1 Answers1

3

Using the properties of floor function, it is evident that

$$ (n\mod i)=n-i\lfloor n/i\rfloor $$

Consequently, we have

$$ \sum_{i\le n}(n\mod i)=n^2-\sum_{i\le n}i\lfloor n/i\rfloor $$

To continue, all we need is to estimate the remaining sum:

\begin{aligned} \sum_{i\le n}i\lfloor n/i\rfloor &=\sum_{i\le n}i\sum_{j\le n/i}1=\sum_{ij\le n}i \\ &=\sum_{j\le n}\sum_{i\le n/j}i=\sum_{j\le n}\left[{n^2\over2j^2}+\mathcal O\left(\frac nj\right)\right] \\ &={n^2\over2}\sum_{j\le n}{1\over j^2}+\mathcal O(n\log n) \end{aligned}

Using the fact that $\sum_{j>n}j^{-2}=\mathcal O(1/n)$, we deduce

$$ \sum_{i\le n}(n\mod i)=\left(1-{\zeta(2)\over2}\right)n^2+\mathcal O(n\log n) $$

Hope this can help you!

TravorLZH
  • 6,718