Number of onto functions: If A & B are two sets having m & n elements respectively such that 1$\le$ n $\le$ m then number of onto functions from A to B is
$\sum^{^n}_{_{_{r-1}}}\left(-1\right)^{n-r} .^{n}C_{r} r^{n}$
Given A =$\left\{1,2,3,---- n\right\}\& B=\left\{a,b,c\right\}$
$\therefore \quad$ Number of onto functions
$=\sum ^{^3}_{_{_{r-1}}}\left(-1\right)^{3-r} .^{3}C_{r} r^{n}$
$=^{3}C_{1}-^{3}C_{2} 2^{n}+^{3}C_{3} 3^{n}$
$=\frac{3!}{2!1!}-\frac{3!}{2!1!} 2^{n} +\frac{3!}{3!0!}3^{n}$
$=3-3.2^{n}+3^{n}$
$=3^{n}-3\left(2^{n}-1\right)$