### Theory:

The natural numbers are $$1$$, $$2$$, $$3$$, $$4$$, …

We need to find the value of $$1^2 + 2^2 + 3^2 + …. + n^2$$.

Consider the identity $$(x + 1)^{k + 1} - x^{k + 1}$$.

Since the power of all the numbers are $$2$$, put $$k = 2$$ in the above identity.

$$(x + 1)^{2 + 1} - x^{2 + 1} = (x + 1)^3 - x^3$$

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

$$= 3x^2 + 3x + 1$$

$$(x + 1)^3 - x^3 = 3x^2 + 3x + 1$$ - - - - (I)

Now, substitute $$x = 1, 2, 3, … n$$ in equation (I).

When $$x = 1$$, $$2^3 - 1^3 = 3(1)^2 + 3(1) + 1$$

When $$x = 2$$, $$3^3 - 2^3 = 3(2)^2 + 3(2) + 1$$

When $$x = 3$$, $$4^3 - 3^3 = 3(3)^2 + 3(3) + 1$$

$$\vdots$$             $$\vdots$$             $$\vdots$$

When $$x = n - 1$$, $$n^3 - (n - 1)^3 = 3(n - 1)^2 + 3(n - 1) + 1$$

When $$x = n$$, $$(n + 1)^3 - n^3 = 3(n)^2 + 3(n) + 1$$

Add all the above equations of $$x$$ values.

$$2^3 - 1^3 + 3^3 - 2^3 + 4^3 - 3^3 + \cdots + n^3 - (n - 1)^3 + (n + 1)^3 - n^3 = 3(1)^2 + 3(1) + 1 + 3(2)^2 + 3(2) + 1 + 3(3)^2 + 3(3) + 1 + \cdots + 3(n - 1)^2 + 3(n - 1) + 1 + 3(n)^2 + 3(n) + 1$$

$$2^3 + 3^3 + 4^3 + \cdots + n^3 + (n + 1)^3 - (1^3 + 2^3 + 3^3 + \cdots + (n - 1)^3 + n^3) = 3(1^2 + 2^2 + 3^2 + \cdots + (n - 1)^2 + n^2) + 3(1 + 2 + 3 + \cdots (n - 1) + n) + (1 + 1 + 1 + ... n \ times )$$

Cancelling the same terms with opposite signs on LHS, we get:

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

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

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

Apply sum of first $$n$$ terms of natural numbers formula in $$1 + 2 + 3 + .. (n - 1) + n$$.

${n}^{3}+3{n}^{2}+3n=3\left({1}^{2}+{2}^{2}+{3}^{2}+...{\left(n-1\right)}^{2}+{n}^{2}\right)+3\left(\frac{n\left(n+1\right)}{2}\right)+n$

${n}^{3}+3{n}^{2}+3n-\frac{3n\left(n+1\right)}{2}-n=3\left({1}^{2}+{2}^{2}+{3}^{2}+...{\left(n-1\right)}^{2}+{n}^{2}\right)$

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

$\frac{2{n}^{3}+3{n}^{2}+n}{2}=3\left({1}^{2}+{2}^{2}+{3}^{2}+...{\left(n-1\right)}^{2}+{n}^{2}\right)$

$\frac{n\left(2{n}^{2}+3n+1\right)}{2}=3\left({1}^{2}+{2}^{2}+{3}^{2}+...{\left(n-1\right)}^{2}+{n}^{2}\right)$

$\frac{n\left(2{n}^{2}+2n\phantom{\rule{0.147em}{0ex}}+n+1\right)}{2×3}={1}^{2}+{2}^{2}+{3}^{2}+...{\left(n-1\right)}^{2}+{n}^{2}$

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

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

Therefore, ${1}^{2}+{2}^{2}+{3}^{2}+...{\left(n-1\right)}^{2}+{n}^{2}=\frac{n\left(n+1\right)\left(2n+1\right)}{6}$
Sum of squares of first $$n$$ natural numbers $$=$$ $\frac{n\left(n+1\right)\left(2n+1\right)}{6}$