You need to derive the formula for:
Sum from j = 0 to N of j^2
There are many different ways to do this, the more advanced math you know, the simpler it gets :).
An elementary method is to consider summing (j+1)^3 - j^3 instead of j^2. Obviously, if you sum a function of the form f(j+1) - f(j), all the terms except the first and last one will cancel:
Sum from j = 0 to N of [f(j+1) - f(j)] =
f(N+1) - f(0)
If we choose f(j) = j^3, then:
f(j+1) - f(j) =
(j+1)^3 - j^3 =
3 j^2 + 3 j + 1
So, if you know the summation of j from zero to N, you can find the summation of j^2. Of course, you can find the formula for the summation of j in the same way by taking f(j) = j^2.