## Sum square difference

We know that the formula for the sum of squares is $$\sum_{k=1}^{n} k^2 = \frac{2n^3 + 3n^2 + n}{6}$$ and that $$\sum_{k=1}^{n} k = \frac{n*(n+1)}{2}$$ (see Arithmetic progression). So we simply need to do $$\sum_{k=1}^{n}k^2 - (\sum_{k=1}^{n}k)^2 = \frac{3n^4 + 2n^3 - 3n^2 - 2n}{12}$$
def equation(n):
equation(100)
25164150