Evaluating $3\lfloor{\frac{n}{2}}\rfloor + 6\lfloor{\frac{n}{2}}\rfloor (n - \lfloor{\frac{n}{2}}\rfloor -1)$ [closed]

$$3\left\lfloor{\frac{n}{2}}\right\rfloor + 6\left\lfloor{\frac{n}{2}}\right\rfloor \left(n - \left\lfloor{\frac{n}{2}}\right\rfloor -1\right) = \frac{3}{2}n(n-1)$$

How do you get the RHS? Do you just do this by considering cases for the floor function or is there a better way?


First, $ n $ needs to be an integer, else the equality would not hold (for example, consider $ n = 1.5 $, for which, $ LHS = 0 $ but $ RHS $ is non-zero). Next, we are left to consider the two cases of odd and even $ n $: $ n = 2k + 1 $ and $ n = 2k $, where $ k $ is an integer. When $ n = 2k + 1 $, $ LHS = 3k + 6k (2k - k) = 3k + 6k^2 = (3/2) 2k (1 + 2k) = RHS $. When $ n = 2k $, it is easier.