# Compute $S = \sum_{k=0}^{m} \left\lfloor \frac{k}{2}\right\rfloor$

I want to compute the following sum $$S = \sum_{k=0}^{m} \left\lfloor \frac{k}{2}\right\rfloor.$$ Here is what I tried: $$S = \sum_{k\geq 0, 2|k}^{m} \left\lfloor \frac{k}{2}\right\rfloor + \sum_{k\geq 0, 2\not |k}^{m} \left\lfloor \frac{k}{2}\right\rfloor.$$ If $$m= 2t$$ then $$S =\sum_{k\geq 0, 2|k}^{m} \left\lfloor \frac{k}{2}\right\rfloor + \sum_{k\geq 0, 2\not |k}^{m} \left\lfloor \frac{k}{2}\right\rfloor = \frac{t(t+1)}{2} + \frac{(t-1)t}{2} = t^2.$$ If $$m= 2t+1$$ then $$S = \sum_{k\geq 0, 2|k}^{m} \left\lfloor \frac{k}{2}\right\rfloor + \sum_{k\geq 0, 2\not |k}^{m} \left\lfloor \frac{k}{2}\right\rfloor = \frac{t(t+1)}{2} + \frac{t(t+1)}{2}= t(t+1).$$

But I am not sure if this is correct. Perhaps someone could give an indication.

• You can write $t$ in terms of $m$ in each case. – model_checker Jan 11 at 8:35
• @Hello_World Actuallly, you can. – 5xum Jan 11 at 8:38
• Are you asking me to write them in terms of $m$? I can do that if it helps. – model_checker Jan 11 at 8:39
• @KemonoChen, please write that as an answer so that we can downvote it. – Carsten S Jan 11 at 14:42

Yes, you are correct. You may also write the result as a more compact formula: $$\sum_{k=0}^{m} \left\lfloor \frac{k}{2}\right\rfloor= \begin{cases} t^2&\text {if m=2t}\\ t(t+1)&\text {if m=2t+1}\\ \end{cases}=\left\lfloor \frac{m^2}{4}\right\rfloor.$$ Indeed, if $$m=2t$$ then $$\left\lfloor \frac{m^2}{4}\right\rfloor=\left\lfloor t^2\right\rfloor=t^2$$ and if $$m=2t+1$$ then $$\left\lfloor \frac{m^2}{4}\right\rfloor=\left\lfloor t^2+t+\frac{1}{4}\right\rfloor=t(t+1).$$