Question
Given an Alphabet of size $ k $ how many strings / numbers of length $ n \geq k $ with each element of the Alphabet appearing at least once?
Example
Example of specific case.
The Alphebet being $ \left\{ 1, 2, 3, 4 \right\} $ and $ n = 7 $.
Then the answer is the number of 7 digits numbers with the digits $ 1, 2, 3, 4 $ appearing at least once in them.
Approach
I thought one could build something in Dynamic Programming approach with Inclusion / Exclusion.
Let's define $ F \left( n, k \right) $ as the answer for $ n, k $.
Then $ F \left( n, k + 1 \right) = {\left( k + 1 \right)}^{n} - \sum_{i = 1}^{k} \binom{k + 1}{i} F \left( n, i \right) $. Where simply we took all numbers of $ n $ digits and removed those built with smaller Alphabet.
I'm not sure about $ F \left( n + 1, k \right) $.
Feel free to give any kind of answer / approach which deals with it.
What we need to count is the number of surjective functions from a set with $n$ elements (the positions in the string) to a set with $k$ elements (the characters in the alphabet).
If there were no restrictions, we would have $k$ choices for each of the $n$ positions in the string. Hence, there are $n^k$ possible strings. From these, we must exclude those strings in which fewer can $k$ characters appear. There are $\binom{k}{j}$ ways to exclude $j$ of the $k$ characters from the string and $(k - j)^n$ ways to fill the string of length $n$ with the remaining $k - j$ characters in the alphabet. By the Inclusion-Exclusion Principle, the number of such strings is $$\sum_{j = 0}^{k} (-1)^j\binom{k}{j}(k - j)^n$$ In your example of strings of length $7$ over the alphabet $\{1, 2, 3, 4\}$, we obtain $$\sum_{j = 0}^{4} (-1)^j\binom{4}{j}(4 - j)^7 = 4^7 - \binom{4}{1}3^7 + \binom{4}{2}2^7 - \binom{4}{3}1^7 + \binom{4}{4}0^7$$ strings in which each number is used at least once.