For example, $2 n \geqslant 3$. Form $n$-digit numbers using the digits $1,2,3$ (each digit can be repeated), where $1,2,3$ each appear at least once. Find the number of such $n$-digit numbers.
Let the set of $n$-digit numbers formed by the digits $1, 2, 3$ be denoted as $I$ (the universal set), and the set of $n$-digit numbers that do not contain the digit $i$ be denoted as $A_{i}(i=1,2,3)$. Then,
$$
|I|=3^{n},\left|A_{1}\right|=\left|A_{2}\right|=\left|A_{3}\right|=2^{n},
$$
| $A_{i} \cap A_{3}|=1(1 \leqslant i<j \leqslant 3),| A_{1} \cap A_{2} \cap A_{3} \mid=0$. By the principle of inclusion-exclusion,
$$
\begin{aligned}
& \left|\left(A_{1} \cup A_{2} \cup A_{3}\right)^{\prime}\right|=|I|-\left|A_{1} \cup A_{2} \cup A_{3}\right| \\
= & 3^{n}-\left(2^{n}+2^{n}+2^{n}-1-1-1+0\right) \\
= & 3^{n}-3 \times 2^{n}+3 .
\end{aligned}
$$