<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] Since 
$$(x-i)(x-i-1)=\frac13\left((x-i-1)(x-i)(x-i+1)-(x-i-2)(x-i-1)(x-i)\right)$$
one has
$$\begin{align}\sum_{i=0}^{k}\binom{x-i}{2}&=\sum_{i=0}^{k}\frac{(x-i)(x-i-1)}{2}\\&=\frac 12\sum_{i=0}^{k}\frac 13\left((x-i-1)(x-i)(x-i+1)-(x-i-2)(x-i-1)(x-i)\right)\\&=\frac 16\sum_{i=0}^{k}\left((x-i-1)(x-i)(x-i+1)-(x-i-2)(x-i-1)(x-i)\right)\\&=\frac 16\left((x-1)x(x+1)-(x-k-2)(x-k-1)(x-k)\right)\\&=\frac{k+1}{2}x^2-\frac{(k+1)^2}{2}x+\frac{k(k+1)(k+2)}{6}\end{align}$$
</s>