How many distinct functions $f : \{1, 2, 3, 4, 5 \} \to \{1, 2, 3 \}$ are there?

4.2k Views Asked by At

How many distinct functions $f : \{1, 2, 3, 4, 5 \} \to \{1, 2, 3 \}$ are there, from the set $\{1, 2, 3, 4, 5\}$ to the set $\{1, 2, 3\}$, whose range is a set of size exactly $2$?

I got $3^5$ total number of functions but don't know how to go further?

2

There are 2 best solutions below

1
On

We first need to decide which elements comprise the function's range. There are $\binom32=3$ ways of doing so.

Then for each element in the domain of the function, we need to decide whether it maps to the smaller or larger element in that chosen range. There are $2^5=32$ ways of doing so, but two of them map all elements in the domain to only one element in the codomain, so are excluded. Thus there are 30 possible functions for each choice of range, and 90 functions in all satisfying the given conditions.

2
On

You can choose a two element set from $\{1,2,3\}$ in $\binom 32=3$ ways, and for each such choice there exists $2^5$ many functions. But 2 of them are constant. Thus, for each two element set of the range, there are $2^5-2$ number of non constant functions. So, the total number of required functions are $3\times(2^5-2)=90.$