<s>[INST] Need a more compact formula This is a part of solution of a programming contest problem
$$\sum_{i=0}^{k} {x-i \choose 2} $$ given $x-i \ge 2$ is always true.
for 
$k=1$,$(x-1)^2$
$k=2$, $(x-1)^2+((x-2)*(x-3)/2)$
$k=3$, $(x-1)^2 + (x-3)^2$
and so on.
Is there a reduced form of this?
 [/INST] $$\frac{1}{2}\sum_{i=0}^k (x-i)(x-i-1) = \frac{1}{2} \left( \sum_{i=0}^k (x^2-2xi+i^2 + x-i) \right) =$$
$$=\frac{1}{2} \left( \sum_{i=0}^k (x^2+ x) + \sum_{i=0}^k (-2xi-i) + \sum_{i=0}^k i^2\right)= \frac{1}{2} \left( (k+1)(x^2+x) -(2x+1)\left(\frac{k(k+1)}{2} \right) + \frac{k(k+1)(2k+1)}{6}\right)$$
</s>