Find the number of functions which are onto

functions

Given a function $f:A\to B$ where $A=\{1,2,3,4,5\}$ and $B=\{6,7,8\}$. Find the number of functions $y=f(x)$ which are onto.

(A)243 (B)93 (C)150 (D)None of these

My Approach:

Since the function is said to be onto each element in set A has an image in set B. There are 5 elements in set A, and each element in set A can take any of the 3 values of B, so for each element in A there are 3 possibilities. So, total number of functions is $3^5=243$ by multiplication theorem.

But the answer is given as 150 (option (C)).

How it this possible, please explain.

Best Answer

One of the $243$ functions from $A$ to $B$ sends every element to $6$. Neither $7$ nor $8$ are in the range of the function, so it is not onto $B$. You need to count the functions that send at least one element to each of $6,7,8$. This is easiest done by inclusion-exclusion. Start with the $243$ functions, subtract all those that skip one of the elements in $B$ in their range, then note that you have subtracted the ones like my example that have just one element in their range twice, so add them back once.

Related Question