Computing a sum involving the floor function

If $n$ is a natural number and $x$ is a real number, compute the sum

$$\sum_{0 \leqslant i < j\leqslant n}\left\lfloor \frac{x + i}{j}\right\rfloor$$

I have tried substituting some numbers to try and see a pattern, but I do not seem to be getting anywhere. I think the solving the problem would involve the use of Hermite's identity (as they look pretty similar).

Thanks for your help.


Look at the difference between sums of $n$ and $n-1$ terms. It is fairly trivial once you can see that and find the pattern.

(DO NOT READ BELOW THIS IF YOU WANT TO TRY AND SOLVE IT YOURSELF AGAIN WITH THIS HINT)

Here is a solution

Let the sum be $S_n$. By looking at the difference between sums :

$$S_n - S_{n-1} = \Bigl\lfloor \frac{x}{n}\Bigr\rfloor + \Bigl\lfloor \frac{x+1}{n}\Bigr\rfloor+...+\Bigl\lfloor \frac{x+n-1}{n}\Bigr\rfloor$$

$$ = \Bigl\lfloor \frac{x}{n} \Bigr\rfloor + \Bigl\lfloor \frac{x}{n} + \frac{1}{n}\Bigr\rfloor + ... + \Bigl\lfloor \frac{x}{n} + \frac{n-1}{n}\Bigr\rfloor$$

and, by Hermite’s identity,

$$S_n - S_{n-1} = \Bigl\lfloor n\frac{x}{n} \Bigr\rfloor = \Bigl\lfloor x \Bigr\rfloor$$

As $S_1 = \Bigl\lfloor x \Bigr\rfloor$, it follows that $S_n = n\Bigl\lfloor x \Bigr\rfloor$ for all $n \geqslant 1$.