<s>[INST] Proving the general formula [nx] where [.] is the floor function. I've been trying to solve a exercise that asks me to prove the following generalization for the floor function:
$$\lfloor nx\rfloor = \sum_{k=0}^{n-1} {\lfloor x + \frac kn \rfloor}$$
I've already proven the special cases where $n = 1,2,3$. I proved it as follows:
$Case \;(i) \;x \in Z: $
$ If\;x \in Z,\; 2x \in Z.\;$
$$\lfloor2x\rfloor = 2x = x + x = \lfloor x\rfloor+\lfloor x + \frac 12 \rfloor$$
$Case \;(ii)\;x \in R - Z:$
$Let \;y = \lfloor x\rfloor.\;$
$$y \lt x \lt y + 1 \\\Rightarrow 2y \lt 2x \lt 2y + 2 \\\Rightarrow 0 \lt 2x - 2y \lt 2$$
$Subcase \;(a)\; 0 \lt 2x - 2y \lt 1 \Rightarrow 0 \lt x - y \lt \frac 12:
Since\; x - y < 0.5,\; \lfloor x\rfloor = \lfloor x +\frac12\rfloor\;given\;that\;y=\lfloor x\rfloor.$
$$0 \lt 2x - 2\lfloor x\rfloor\lt 1\\\Rightarrow 2\lfloor x\rfloor \lt 2x \lt 2\lfloor x\rfloor+1\\\Rightarrow\lfloor 2x\rfloor = 2\lfloor x\rfloor = \lfloor x\rfloor+\lfloor x\rfloor = \lfloor x\rfloor + \lfloor x + \frac 12\rfloor$$
$Subcase \;(b) \;1 \lt 2x - 2y \lt 2 \Rightarrow \frac 12 \lt x - y \lt 1 \Rightarrow \lfloor x\rfloor+1 = \lfloor x +\frac12\rfloor\;given\;that\;y=\lfloor x\rfloor.$
$$1 \lt 2x - 2\lfloor x\rfloor\lt 2\\\Rightarrow 2\lfloor x\rfloor +1\lt 2x \lt 2\lfloor x\rfloor+2\\\Rightarrow\lfloor 2x\rfloor = 2\lfloor x\rfloor +1= \lfloor x\rfloor+\lfloor x\rfloor +1= \lfloor x\rfloor + \lfloor x + \frac 12\rfloor$$
$QED:\;\lfloor 2x \rfloor = \lfloor x\rfloor + \lfloor x + \frac 12\rfloor$
I've proven for n = 3 similarly. Can somebody suggest a way to generalise it for all n, where n is a positive integer? This is not a homework question, but I would like if you only guide me in the right direction, instead just telling me the answer.
 [/INST] Here is a classical neat solution:
Let 
$$f(x)= \lfloor nx\rfloor - \sum_{k=0}^{n-1} \lfloor x + \frac kn \rfloor$$
Then the following are immediate:


*

*$f(x+\frac{1}{n})=f(x)$.

*$f(x)=0$ for all $x \in [0, \frac{1}{n})$.


Moreover, any function satisfying these two must be identically 0.
</s>