TITLE: Show that if $x\geq 0$ and $n$ is a positive integer, then $\sum_{k=0}^{n-1}\left\lfloor {x+\frac{k}{n}}\right\rfloor=\lfloor {nx}\rfloor$
QUESTION [5 upvotes]: I need help with this question, where $\lfloor x\rfloor$ means the floor function of $x$.
Show that if $x\geq 0$ and $n$ is a postive integer, then $$\sum_{k=0}^{n-1}\left\lfloor x+\frac{k}{n} \right\rfloor =\lfloor nx\rfloor$$

REPLY [2 votes]: For given $x\in{\mathbb R}$ write
$$x=j+{r\over n}+\xi\qquad{\rm with}\qquad j\in{\mathbb Z}, \quad 0\leq r<n, \quad 0\leq\xi<{1\over n}\ .$$
Then
$$\lfloor nx\rfloor=\lfloor nj + r+n\xi\rfloor=nj+r\ .$$
On the other hand
$$\left\lfloor x+{k\over n}\right\rfloor=\left\lfloor j+{r+k\over n}\right\rfloor=\cases{j\quad&$(0\leq k<n-r)$ \cr 
j+1\quad&$(n-r\leq k<n)$\cr}$$
and therefore
$$\sum_{k=0}^{n-1}\left\lfloor x+{k\over n}\right\rfloor= nj + r\ ,$$
as above.