$$1^2 + 2^2 + … + n^2 = \frac{n(n + 1)(2n + 1)}{6}$$

### 立方差公式

$$a^2 - b^2 = (a + b)(a - b)$$

$$a^3 - b^3 = (a - b)(a^2 + ab + b^2)$$

$$(a - b)^3 = (a - b)^2(a - b) = (a^2 - 2ab + b^2)(a - b)$$

$$= a^3 - a^2b - 2a^2b + 2ab^2 + ab^2 - b^3 = a^3 - 3a^2b + 3ab^2 - b^3$$

$$a^3 - b^3 = (a - b)^3 + 3a^2b - 3ab^2 = (a - b)^3 + 3ab(a - b) = (a - b)((a - b)^2 + 3ab)$$

$$= (a - b)(a^2 - 2ab + b^2 + 3ab) = (a - b)(a^2 + ab + b^2)$$

### 1 至 n 的平方和公式

$$n^3 - (n - 1)^3 = (n - (n - 1))(n^2 + n(n - 1) + (n - 1)^2)$$ $$= n^2 + n^2 - n + n^2 - 2n + 1 = 3n^2 - 3n + 1$$

$$(n - 1)^3 - (n - 2)^3 = (n - 1 - (n - 2))((n - 1)^2 + (n - 1)(n - 2) + (n - 2)^2)$$ $$= (n - 1)^2 + (n - 1)(n - 1 - 1) + (n - 1 - 1)^2$$ $$= (n - 1)^2 + (n - 1)^2 - (n - 1) + (n - 1)^2 - 2(n - 1) + 1$$ $$= 3(n - 1)^2 - 3(n - 1) + 1$$

$$2^3 - 1^3 = 3*2^2 - 3 * 2 + 1$$

$$1^3 - 0^3 = 3*1^2 - 3 * 1 + 1$$

$$n^3 - 0^3 = 3(1^2 + 2^2 + … + n^2) - 3(1 + 2 + … + n) + n$$

$$3(1^2 + 2^2 + 3^2 + … + n^2) = n^3 + 3(1 + 2 + … + n) - n$$

$$1^2 + 2^2 + … + n^2 = \frac{n^3 - n}{3} + \frac{(1 + n)n}{2}$$

$$= \frac{2n^3 - 2n + 3(n + 1)n}{6} = \frac{n(2n^2 + 3n + 1)}{6} = \frac{n(n + 1)(2n + 1)}{6}$$