One of our multi-stage problems, that get harder as you work through them. And then a challenge to find a generic solution.

Firstly consider a three-inch cube that is completely painted on all six faces. This cube is sawed into one-inch cubes. Some of the resulting one-inch cubes will have paint on three faces, some on two faces, some on one face, and some with no paint at all.

How many of each are there?

If this was easy enough, consider a four-inch cube. This is sawed into one-inch cubes. How many of these have paint on three, two, one and no faces?

You can keep going with this with bigger and bigger cubes, but perhaps it would be more fun to work out the general formula for each of the four types of one-inch cubes for an n-inch cube.

With the three-inch cube there will be 27 one-inch cubes, made up as follows:

The eight on the corners will have three painted faces.

The twelve on each edge will have two painted faces.

The six in the middle of the faces will have one painted face.

And the one in the middle will have no painted faces.

Moving onto the four-inch cube, there will be 64 one-inch cubes, made up as follows:

The eight on the corners will have three painted faces.

24, that is two on each edge, will have two painted faces.

24, that is four in the middle of the six faces will have one painted face.

And the eight in the cube in the middle will have no painted faces.

So, a generic solution . . .

There will always be eight corners so there will always be eight cubes with three painted faces.

There are twelve edges with (n-2) cubes on them, so there are 12(n-2) cubes with two painted faces.

There are six faces with (n-2)^2 cubes on them, so there are 6(n-2)^2 cubes with on painted face.

And there is a cube in the middle of the cube with (n-2)^3 one-inch cubes in it, so there are (n-2)^3 cubes with no painted faces.