How many ways to colorize the table Each cell of a square table of 3 × 3 can be painted black, white or red. How many different colorings of this table? If we do not consider the turnings of the board, we get $3^9$ variants. How many variants of coloring will be, if you consider the possibility of turning the board?
I can sort through all the options for a 2 × 2 table and two colors (16 variants without rotation and 6 variants with turns), but for 3 × 3 variants too much.
 A: The formula is Burnside's Lemma. You take a group, in this case the group of rotations of a square: $0, 90, 180, 270$ degree rotations, and look at which colourings are fixed by each rotation. The formula is

$$ \frac{1}{\text{size of group}}\left( \text{colourings fixed by the first group element} + \text{colourings fixed by the second group element} + \cdots \right) $$

In this case


*

*$3^9$ colourings are fixed by a $0$ degree rotation

*$3^3$ colourings are fixed by a $90$ or $270$ degree rotation (such colourings are determined by how the top-left, top-centre and centre squares are coloured)

*$3^5$ colourings are fixed by a $180$ degree rotation (determined by the top three squares and the centre-left and centre squares)
Applying Burnside's Lemma, there are
$$ \frac14 \left( 3^9 + 2 \cdot 3^3 + 3^5 \right) = 4995 $$
distinct colourings.
A: If you are interested in the number of "essentially different" colorings, then you may want to note that in the $2 \times 2$ table with two colors considering rotations is enough, but in general, there are 8 symmetries of the square.
Besides the rotations by multiples of 90 degrees, there are four "flips:" horizontal, vertical, and along the two main diagonals. The method described by @TrevorGunn still applies, but you also need to compute the number of colorings that are fixed under each flip, which turns out to be $3^6$ for each flip.  All in all, 
$$ \frac{3^9 + 2 \cdot 3^3 + 3^5 + 4 \cdot 3^6}{8} = 2862 \enspace. $$
For the $2 \times 2$ table with two colors, there are $2^2$ colorings fixed under horizontal and vertical flips, and $2^3$ colorings that are fixed under diagonal flips.  Compared to rotations only, the four flips double both numerator and denominator, leaving the final number of colorings unchanged:
$$ \frac{2^4 + 2 \cdot 2^1 + 2^2 + 2 \cdot 2^2 + 2 \cdot 2^3}{8} = 6 \enspace. $$
Finally, note that you cannot apply Burnside's lemma to flips only, because, unlike rotations, they do not form a group (they are not closed under composition).
