How to find a general equation for the number of colored smaller cubes on a large cube? Let's say I have a wooden cube which is painted all blue and cut into 3 by 3 by 3 smaller pieces. These smaller cubes are placed into a box. One cube from the box is thrown. 
What is the probability that a painted side turns up?
Ans: $$(6/27 * 1/6) + (12/27 * 2/6) + (12/27 * 2/6) + (8/27 * 3/6)$$
If the painted wooden cube was cut into n^3 smaller cubes and these cubes were put into a box and one randomly chosen from the box and thrown, give an expression for the probability that a painted side turns face up. You should explain your reasoning in calculating your answer. 
The general equation should be (8/n^3) * (3/6) + 12(n-2)/(n^3) * (2/6) + 6(n-2)^2/n^3  * 1/6
I am unsure of why the (n-2) starts of with no power with the 12 then becomes (n-2)^2 with the 6. What is the reason for this? And why is n-2 needed?
Thanks
 A: $3\times 3\times 3$ cube is cut into $27$ smaller $1\times 1\times 1$ cubes. Let $A,B,C,D$ be the events with $0,1,2,3$ sides painted. Then:
$$n(A)=1 \ \text{(the central cube inside)}\\
n(B)=6 \ \text{(the central cubes on the the faces)}\\
n(C)=12 \ \text{(the central cubes on the edges)}\\
n(D)=8 \ \text{(the cubes on the vertices)}$$
Let $P$ be the event of being painted side, then:
$$P(A)\cdot P(P|A)+P(B)\cdot P(P|B)+P(C)\cdot P(P|C)+P(D)\cdot P(P|D)= \\
\frac{1}{27}\cdot \frac{0}{6}+\frac{6}{27}\cdot \frac{1}{6}+\frac{12}{27}\cdot \frac{2}{6}+\frac{8}{27}\cdot \frac{3}{6}=\frac13.$$
Alternatively, $6\times 9$ unit faces are painted out of $6\times 27$ total number of unit faces, which results in $1/3$.
A: Like what @farruhota said for general we have:
$$\begin{array}{*5c}
n(A) & = & (\text{The Central Cube Inside With No Colored Face})          & = & 1(n-2)^3 \\
n(B) & = & (\text{The Central Cubes On The Faces With One Colored Face})  & = & 6(n-2)^2 \\
n(C) & = & (\text{The Central Cubes On The Edges With two Colored Faces}) & = & 12(n-2)^1\\
n(D) & = & (\text{The Cubes On The Vertices With Three Colored Faces})     & = & 8(n-2)^0 \\
\\
P & = & \frac{1}{6}.\frac{1}{n^3}.(0.n(A) + 1.n(B) + 2.n(C) + 3.n(D)) & = & \dots\\
\end{array}$$
Some explanation:
$A$: is internal cube that remains when you remove all border cubes. So it has $(n-2)$ cubes in any of its sides.
$B$: We have $6$ faces. On each face there is a internal surface, that remains when you remove all border cubes. So it has $(n-2)$ cubes in any of its edges.
$C$: We have $12$ edges. On each edge there is internal segment of cubes that remains when you remove first and last cubes. So it has $(n-2)$ cubes.
$D$: We have $8$ vertices.
