# How do I evaluate this sum(involving the floor function)?

$$\sum_{i=1}^N\left\lfloor\frac{N}{i}\right\rfloor$$ Is there a closed form expression to the above sum? (Mathematica doesn't give me anything)

-
$N\ln(N)$ would be a good approximation. – Sabyasachi Apr 5 '14 at 6:40
It doesn't have an exact closed form. – Sabyasachi Apr 5 '14 at 6:41
Can you give me a reference? – Priyatham Apr 5 '14 at 6:41
@howardh. No, take N = 8, i = 3. $\lfloor \frac{8}{3}\rfloor = 2$ – Priyatham Apr 5 '14 at 7:03
@Priyatham Right, I don't know what I was thinking. – howardh Apr 5 '14 at 7:04

This is Dirichlet's divisor summatory function $D(x)$. It is known that $$D(x) = x\log x + x(2\gamma -1) + \Delta(x)$$ and the non-leading term $\Delta(x)$ is $O(\sqrt{x})$. Forget about its closed form, even the behaviour of the non-leading term $\Delta(x)$ is a well known unsolved problem.

Dirichlet divisor problem

Find the smallest value of $\theta$ for which $\Delta(x) = O(x^{\theta+\epsilon})$ holds true for all $\epsilon > 0$.

-
Thanks for the answer and the link. In the end I used the $O(\sqrt{x})$ formula for evaluating this sum. – Priyatham Apr 5 '14 at 7:44

$$\sum_{i=1}^N \left \lfloor \frac{N}{i}\right\rfloor \approx \sum_{i=1}^N \frac{N}{i} = N\sum_{i}^N \frac1{i} = NH_N$$

where $H_n$ is the nth Harmonic number.

For any monotonically decreasing function $f$ we have,

$$\int_1^{n+1}f(x)\,{\rm d}x \le \sum_{i=1}^n f(i) \le 1+\int_1^nf(x)\,{\rm d}x$$

Taking $f(x)=\frac1{x}$, we obtain the well known bound,

$$\ln(n+1)\le H_n\le 1+\ln(n)$$

Thus $H_n \sim \ln(n)$

and our sum is $$S=N\ln(N)$$

Note: $H_n=\ln(n) + \gamma$ is a better approximation, where $\gamma$ is the Euler Mascheroni Constant.

We can always say that

$$N\ln(N+1) \le S \le N + N\ln(N)$$

-
Yes I did. But like told @V.C., I need an exact answer. Also, when you say $n$, do you mean $N$? – Priyatham Apr 5 '14 at 7:01
@Priyatham yes I corrected the typo. But till date a closed form hasn't been found. – Sabyasachi Apr 5 '14 at 7:08
Also, since it's a discontinuous function on integers, you can be almost sure that an analytic closed form doesn't exist. – Sabyasachi Apr 5 '14 at 7:09
@Priyatham. There is no hope to arrive to any closed form solution (as already other wrote). The only thing you can hope is to find upper and lower bounds and what Sabyasachi answered is probably almost the best you could get. – Claude Leibovici Apr 5 '14 at 7:25
Why is the possibility of a closed form so pessimistically viewed? As far as I understand, Sabyasachi's approximation is already asymptotic to the true value of the function. Now, why does the discontinuity by it self make it "almost sure" that a better, perhaps, exact analytical closed form does not exist - like the gamma function for the factorials? – Just_a_fool Apr 5 '14 at 9:58

The sequence $a_n=\sum_{k=1}^{n}\left\lfloor\frac{n}{k}\right\rfloor$ is integer sequence A006218 in the OEIS. It is equal to a function called the divisor summatory function; i.e., it is equal to the sum over the divisor function:

$$a_n=\sum_{k=1}^{n}\left\lfloor\frac{n}{k}\right\rfloor=\sum_{k=1}^{n}d(k)=D(n).$$

-