Number of surjective functions from a set $\{1,2,\dots,k\} \to \{1,2,\dots,n\}$, I don't get a thing...

51 Views Asked by At

Here is what I have, after a little introduction:

Let's calculate the number of surjective functions $f_k: \{1,2,\dots,k\} \to \{1,2,\dots,n\}$. We start observing that every function is surjective on its own image. Then if $n \ge 1$ and for each $j \in [1,n]\cap\mathbb{N}$ we denote with $A_j$ the class of all the functions $f_k: \{1,2,\dots,k\} \to \{1,2,\dots,n\}$ whose images have exactly $j$ elements. Then we have that

$n^k = |F_k^n| = \sum_{j=1}^{n}|A_j|$

Where $|F_k^n|$ is the number of strings of $k$ character that can be selected from an alphabet of $n$ items.

I don't get why that equality is true. Any idea?