Error in proving of the formula the sum of squares Given formula
$$
\sum_{k=1}^n k^2 = \frac{n(n+1)(2n+1)}{6}
$$
And I tried to prove it in that way:
$$
\sum_{k=1}^n (k^2)'=2\sum_{k=1}^n k=2(\frac{n(n+1)}{2})=n^2+n
$$
$$
\int (n^2+n)\ \text d n=\frac{n^3}{3}+\frac{n^2}{2}+C
$$
But 
$$
\frac{n^3}{3}+\frac{n^2}{2}+C $$ is not equal to 
$$\frac{n(n+1)(2n+1)}{6}=\frac{n^3}{3}+\frac{n^2}{2}+\frac{n}{6}$$
Where I made a mistake?

This is from An Introduction to the Calculus of Finite Differences and Difference Equations by Kenneth S. Miller, 1960. 
We have the difference operator $$ \Delta f(x) = f(x+1) - f(x)  $$
Then we have the factorial polynomials,
$$ x^{(0)} =1,  $$
$$ x^{(1)} =x,  $$
$$ x^{(2)} =x(x-1) = x^2 - x,  $$
$$ x^{(3)} = x(x-1)(x-2) = x^3 - 3 x^2 + 2 x,  $$
$$  x^{(n+1)} = (x-n) x^{(n)} .  $$ 
The pretty difference result is
$$ \Delta  x^{(n)} = n x^{(n-1)}   $$
Without endpoints, indefinite, the fundamental theorem applies as
$$ \sum  x^{(n)} = \frac{x^{(n+1)}}{n+1}, \; \; \; \;  n \neq -1  $$
and with endpoints, we get a shift from $N$ to $N+1$ corresponding to the definition of $\Delta,$ with
$$ \sum_{x=1}^N  x^{(n)} = \left. \frac{x^{(n+1)}}{n+1} \right|_{x=1}^{x=N+1}. \; \; \; \;  n \neq -1  $$
So now we use $$ x^2 = x^2 - x + x = x(x-1) + x  = x^{(2)} + x^{(1)} $$
and find (page 26)
$$ \sum_{x=1}^N  x^{(2)} + x^{(1)} = \left. \frac{x^{(3)}}{3} + \frac{x^{(2)}}{2} \right|_{x=1}^{x=N+1} =  \left. \frac{x(x-1)(x-2)}{3} + \frac{x(x-1)}{2} \right|_{x=1}^{x=N+1} $$
$$ =   \frac{(N+1)N(N-1)}{3} + \frac{(N+1)N}{2}  $$
$$ = \frac{1}{6} (N+1)N \left( 2(N-1) + 3 \right) = \frac{1}{6} (N+1)N \left( 2N-2 + 3 \right) = \frac{1}{6} (N+1)N \left( 2N + 1 \right) .$$
