I know that the closed-form of $\sum_{i=1}^n i^2$ is $n(n+1)(2n+1)/6$.
But how to derive the formula through integration? My attempt is
$$ \sum_{i=1}^n i = \frac{n^2+n}{2}\\ \frac{1}{2}\sum_{i=1}^n i^2 = \frac{n^3}{6}+\frac{n^2}{4}\\ \sum_{i=1}^n i^2 = \frac{n^3}{3}+\frac{n^2}{2}\\ $$ My result is obviously not true, but why? Is there a way to derive the formula through integration?
Thank you for your effort!