TITLE: Number of onto functions from $Y$ to $X$ (JEE Advanced 2018)
QUESTION [8 upvotes]: Let $X$ be a set with $5$ elements and $Y$ be a set with $7$ elements. If $\beta$ is the number of onto functions from $Y$ to $X$ then the value of $\dfrac{\beta}{5!}$ is?

My approach is: 
First I give each element of $Y$ one element of $X$ which then leaves me with two possibilities for the remaining two elements of $Y$. 
1) Both can take same value
2) Both take different value from X. 
So number of onto functions = $\beta = {^7}C_5\times 5! \times(5+ 5\times4)$ but this is wrong. 
What's my mistake? 
Also, I know how to solve the problem using principle of inclusion exclusion and that gives the right answer but we are not given calculators in exam and the calculation involved there is very lengthy.

REPLY [3 votes]: Your method counts each surjective function that maps three elements of $Y$ to one element of $X$ three times, once for each way you could designate one of those three elements as the element of $Y$ that maps to that element of $X$.
For example, consider the surjective function $f: Y \to X$ defined by $f(1) = 1$, $f(2) = 2$, $f(3) = 3$, $f(4) = 4$, $f(5) = f(6) = f(7) = 5$.  You count this function three times:
\begin{array}{c | c}
\text{designated ordered pairs} & \text{additional ordered pairs}\\ \hline
(1, 1), (2, 2), (3, 3), (4, 4), (5, 5) & (6, 5), (7, 5)\\
(1, 1), (2, 2), (3, 3), (4, 4), (6, 5) & (5, 5), (7, 5)\\
(1, 1), (2, 2), (3, 3), (4, 4), (7, 5) & (5, 5), (6, 5)\\
\end{array}
where we have written $(y, x)$ if $f(y) = x$.
You count each surjective function that maps two elements of $Y$ to one element of $X$ and two other elements of $Y$ to a different element of $X$ four times, twice for each pair of elements of $Y$ that map to a single element of $X$.
For example, consider the surjective function $f: Y \to X$ defined by $f(1) = 1$, $f(2) = 2$, $f(3) = 3$, $f(4) = f(6) = 4$, $f(5) = f(7) = 7$.  You count this function four times:
\begin{array}{c | c}
\text{designated ordered pairs} & \text{additional ordered pairs}\\ \hline
(1, 1), (2, 2), (3, 3), (4, 4), (5, 5) & (6, 4), (7, 5)\\
(1, 1), (2, 2), (3, 3), (6, 4), (5, 5) & (4, 4), (7, 5)\\
(1, 1), (2, 2), (3, 3), (4, 4), (7, 5) & (6, 4), (5, 5)\\
(1, 1), (2, 2), (3, 3), (6, 4), (7, 5) & (4, 4), (5, 5)\\
\end{array}
Let's correct your count.
Surjective functions in which exactly three elements of $Y$ map to a single element of $X$: Choose which three of the seven elements of $Y$ map to a single element of $X$.  Choose that element of $X$.  Since the function is surjective, the remaining four elements must map to distinct elements from the remaining four elements of $X$.  The number of such functions is 
$$\binom{7}{3}\binom{5}{1}4!$$
Surjective functions in which exactly two elements of $Y$ map to a single element of $X$ and exactly two other elements of $Y$ map to a different element of $X$:  Choose which two of the five elements of $X$ are each the images of two elements of $Y$.  Choose which two of the seven elements of $Y$ map to the smaller of these elements of $X$.  Choose which two of the remaining five elements of $Y$ map to the larger of these elements of $X$.  Since the function is surjective, the remaining three elements of $Y$ must map to distinct elements from the remaining three elements of $X$.  The number of such functions is
$$\binom{5}{2}\binom{7}{2}\binom{5}{2}3!$$
Total:  Since the two cases above are mutually exclusive and exhaustive, the number of surjective functions from $Y$ to $X$ is 
$$\binom{7}{3}\binom{5}{1}4! + \binom{5}{2}\binom{7}{2}\binom{5}{2}3!$$