This problem is most easily solved by visualizing the cube and plugging in simple numbers (for example, n = 3), but it
can be solved geometrically, and in a couple of different ways.
Method 1
The large cube is divided into n^3 smaller cubes. This means that the dimensions of our cube are n x n x n - there are n smaller cubes along each edge.
So for this cube ...
... n is 4, and there are 64 smaller cubes.
We want to know how many of the smaller cubes have at least one side painted red. In other words, we want to know how many of the smaller cubes were originally on the outside of the larger cube.
First, we can find the total number of smaller cube sides that face out. For each side of the large cube, there are n x n smaller cube sides that face out. (In our example cube above, there are 16 smaller cube sides on each large cube side.) We then have 6 larger cube sides, giving us 6n^2.
However, this means that we are double counting all of the cubes that have two sides facing out. All of the smaller cubes along the larger cube's edges have at least two sides facing out, so we can subtract n for each large cube edge. This gives us 6n^2 - 12n.
But now we see that we've unintentionally subtracted out all three sides of the smaller cubes at the corners of the large cube, so we need to add them back in. For 8 corners, that's 8 cubes, giving us 6n^2 - 12n + 8, or answer choice B.
Method 2
Alternatively, we can figure out how many smaller cubes
don't have sides painted red. If we take all of the smaller cubes facing out on the larger cube off, we are left with (n-2)^3 smaller cubes. (So in our example cube, taking off all of the small cubes facing out would leave us with a 2x2x2 cube that did not have any sides painted red, or 8 smaller cubes.)
So to figure out how many cubes
do have painted sides, we can subtract (n-2)^3 (the unpainted cubes) from n^3 (the total number of cubes).
n^3 - (n-2)^3
n^3 - (n^3 - 6n^2 + 12n - 8)
6n^2 + 12n - 8