Series of squares of n integers - where is the mistake?

$$\sum_{i=1}^n i={n(n+1)\over2}\quad\text{ not }\quad {n(n-1)\over2}$$


Your error is when you evaluate $$\sum_{i=1}^n i = \frac{n(n-1)}{2}$$ The correct formula is $$\sum_{i=1}^n i = \frac{n(n+1)}{2}$$ plugging this, everything works.


Note that $\sum_{i=1}^n i = \frac 12n(n{\color{red}+}1)$, hence \begin{align*} \frac 13 \left(n^3 + 3\frac{n(n+1)}2 - n\right) &= \frac 16 n(2n^2 + 3n + 3 - 2)\\ &= \frac 16 n(2n^2 + 3n + 1)\\ &= \frac 16 n(2n+1)(n+1) \end{align*}