I think I'm having a math block these days with things I shouldn't have problems with. Having $|A| = n$ (the number of elements of A is n), and $|B| = p$, and ($n \geq p$), how many surjective functions should I have?
I was developing the following reasoning:
$\sum _{k=1}^{p}x_{k}=n$ is the problem associated with solving n arrows inside p boxes, since we have to complete the counterdomain, I should transform this problem with the change of variables $y_{k}=x_{k}-1$.
This gets me to $\sum _{k=1}^{p}y_{k}=(n-p)$, and the result $\frac{(n-1)!}{(n-p)!(p-1)!}=C_{n-1}^{n-p}$.
I tried some inclusion-exclusion with it, but I can't construct a sequence...
The book says the answer is $\sum _{k=0}^{p}(-1)^{k}C_{p}^{k}(p-k)^n$
Obs.: $C_{n}^{p}=\frac{n!}{(n-p)!(p)!}$