证明1^2+2^2+3^2+.+n^2=n(n+1)(2n+1)/6
证法一
n^2=n(n+1)-n
1^2+2^2+3^2+.+n^2
=1*2-1+2*3-2+.+n(n+1)-n
=1*2+2*3+...+n(n+1)-(1+2+...+n)
由于n(n+1)=[n(n+1)(n+2)-(n-1)n(n+1)]/3
所以1*2+2*3+...+n(n+1)
=[1*2*3-0+2*3*4-1*2*3+.+n(n+1)(n+2)-(n-1)n(n+1)]/3
[前后消项]
=[n(n+1)(n+2)]/3
所以1^2+2^2+3^2+.+n^2
=[n(n+1)(n+2)]/3-[n(n+1)]/2
=n(n+1)[(n+2)/3-1/2]
=n(n+1)[(2n+1)/6]
=n(n+1)(2n+1)/6
证法二
利用立方差公式
n^3-(n-1)^3
=1*[n^2+(n-1)^2+n(n-1)]
=n^2+(n-1)^2+n^2-n
=2*n^2+(n-1)^2-n
2^3-1^3=2*2^2+1^2-2
3^3-2^3=2*3^2+2^2-3
4^3-3^3=2*4^2+3^2-4
.
n^3-(n-1)^3=2*n^2+(n-1)^2-n
各等式全部相加
n^3-1^3=2*(2^2+3^2+...+n^2)+[1^2+2^2+...+(n-1)^2]-(2+3+4+...+n)
n^3-1=2*(1^2+2^2+3^2+...+n^2)-2+[1^2+2^2+...+(n-1)^2+n^2]-n^2-(2+3+4+...+n)
n^3-1=3*(1^2+2^2+3^2+...+n^2)-2-n^2-(1+2+3+...+n)+1
n^3-1=3(1^2+2^2+...+n^2)-1-n^2-n(n+1)/2
3(1^2+2^2+...+n^2)
=n^3+n^2+n(n+1)/2
=(n/2)(2n^2+2n+n+1)
=(n/2)(n+1)(2n+1)
1^2+2^2+3^2+...+n^2=n(n+1)(2n+1)/6