Let A and B be two sets.
$A=\{1,2,\dots m\}$
$B=\{1,2,\dots n\}$
We have to find the number of onto functions from A to B
In the following link , the approach of the answer was applying Inclusion Exclusion to count the complement. Can't we use it directly?
My Approach
Let $J_i$ denote the number of mappings in which there exists a pre-image of $i$.
We need to find $|J_1\cup J_2\cup \dots J_n|$.
From inclusion exclusion we conclude
$$|J_1\cup J_2\cup \dots J_n|=\sum_{i=0}^n|J_i|- \sum_{1\leq i <j\leq n}|J_i\cap J_j| \dots$$
Now, $|J_i| = m * n^{m-1}$
$|J_i\cap J_j|$= $m*(m-1)*n^{m-2}$ and so on.
Then we just put in the values. Is it correct?