<s>[INST] How many 5-digit sequences of $\{1, 2, 3, 4\}$ are there in which $1$, $2$, $3$ and $4$ all appear? I'm trying to work out how many possible 5 digit sequences there are using the numbers $\{1, 2, 3, 4\}$ in which each number appears at least once.
I thought it might be $4\times 3\times 2\times 1\times 4$ but it's not one of the possible answers.
 [/INST] Here's an alternative approach via inclusion-exclusion, where the four properties to be avoided are that $j\in\{1,2,3,4\}$ does not appear:
\begin{align}
\sum_{k=0}^4 (-1)^k \binom{4}{k} (4-k)^5 
&= \binom{4}{0} 4^5 - \binom{4}{1} 3^5 + \binom{4}{2} 2^5 - \binom{4}{3} 1^5 + \binom{4}{4} 0^5 \\
&= 1024 - 972 + 192 - 4 + 0 \\
&= 240
\end{align}
More generally, the number of surjections from an $n$-set onto an $m$-set is
$$\sum_{k=0}^m (-1)^k \binom{m}{k} (m-k)^n$$
</s>