Number of surjective funtions (onto or co-domain = range) from a set of $m$ elements to a set of $n$ elements is same as putting $m$ distinct balls to $n$ distinct buckets such that no bucket is empty. For $m=6, n= 5$, this is given by $S(6,5)*5! = 15 * 120 = 1800$.
But, here we have an additional constarint that $f(6) =3$ for all the functions. So, our answer must be less than 1800.
To find this, we can consider 2 cases
- Let no element map to 3 from $A-\{6\}$, and then add the mapping $(6,3)$.
- Let all elements from $A-\{6\}$ map to all elements of $B$ and then add the mapping $(6,3)$.
Since in each case we are considering surjective mappings (co-domain = range) we are sure that both these cases are mutually exclusive and for the total cases, simple addition is enough. (In the first case 3 is mapped to by just 6, in in the second case 3 is mapped to by at least two elements including 6).
So, now for 1, it is same as number of surjective functions from a set of 5 elements to a set of 4 elements which is $S(5,4)*4! = 10*24= 240$.
For 2, it is same as the number of surjective functions from a set of 5 elements to a set of 5 elements which is $5! = 120$.
Thus totally we can have $240+120=360$ such surjective functions.
$S(m,n)$ is Stirling's number of second kind and is given by the number of ways of partitioning a set of $m$ elements to $n$ partitions. So,
$S(m,1) = S(m,m) = 1$
$S(m,n) = S(m-1, n-1) + n S(m-1, n)$ // This needs explanation
So, $S(3,2) = S(2,1) + 2S(2,2) = 1+ 2 = 3$.
So, we get the triangle
1
1 1
1 3 1
1 7 6 1
1 15 25 10 1
which can be extended as required using the formula $S(m,n) = S(m-1, n-1) + n S(m-1, n)$