# How to find no. of onto functions

Then, If $m\geq n$, No. of onto functions from set A to set B = $n^m-^nC_1(n-1)^m+^nC_2(n-2)^m-...$
For eg. if mapping is done such that there are 5 balls to be put in 5 boxes, then no. of ways of putting, such that no box remains empty (No. of onto functions) = $3^5-^3C_12^5+^3C_21^5 = 150$
If $m then no. of onto functions = 0