We could write a recursion relation.

For \( n=0 \) we need \( 0 \) cubies, so

\( S_0 = 0 \).

Imagine taking an \( n-1 * n-1 \) cube and adding cubies to make it into an \( n * n \) cube.

\( S_n = S_{n-1} + ... \)

You'd have to add a layer of cubies around the outside. Add an \( n * n \) face to R with the extra cubies hanging above U and B. Then add an \( (n-1) * (n-1) \) block to U. Finally add \( (n-1) * n \) to B. That comes to \( 3n^2 - 3n + 1 \) cubies added.

\( S_n = S_{n-1} + 3n^2 - 3n + 1 ... \)

But some old cubies got covered up completely. This happened to stuff in the URB corner of the smaller cube and its vicinity. What got covered up was basically an \( n-2 * n-2 \) cube.

\( S_n = S_{n-1} + 3n^2 - 3n + 1 - S_{n-2}... \)

Part of that \( S_{n-2} \) cube had already been covered, though, so we have to add back in a cube of size \( S_{n-3} \)

\( S_n = S_{n-1} + 3n^2 - 3n + 1 - S_{n-2} + S_{n-3}... \)

et cetera

\( S_n = S_{n-1} + 3n^2 - 3n + 1 - S_{n-2} + S_{n-3} - S_{n-4} + S_{n-5}... S_1 \)

If we plug in the same thing evaluated for \( S_{n-1} \), that whole long alternating summation cancels out, and we have

\( S_n = 3n^2 - 3n + 1 + 3(n-1)^2 - 3(n-1) + 1 \)

which is the same equation mentioned earlier.

It doesn't work for \( S_1 \), though, because \( S_0 \) is simply assigned the value \( 0 \). We cannot make the substitution

\( S_0 = 0^2 + -3*0 + 1 + ... \) because the recursion only applies to higher \( n \).

Instead we just have \( S_1 = 3*1^2 - 3*1 + 1 + S_0 = 1 \).