[Math] $A=\{1,2,3,4,5\}$, $B=\{1,2\}$ How many functions $f:A\rightarrow B$ exists

combinatoricsdiscrete mathematics

I`m trying to calculate how much functions there is for
$A=\{1,2,3,4,5\}$, $B=\{1,2\}$ that
$f:A\rightarrow B$
I know that $f(a_{i})=y\in B $ and only one from A, but there is two option the first that all goes to $1\in B$ and the second that all goes to $2\in B$ so its $5$ for the first and $5$ for the second, how should I continue from here?

another related question that I have is how many functions exists ($f:A\rightarrow A$) Injective and Surjective have on $A=\{1,2, \dots ,n\}$?

thanks!

Best Answer

There is $2^5$ functions. It's a straightforward argument. The number of bijections $\{ 1,2,3,...,n\}\rightarrow\{1,2,3,...,n\}$ are n!. for the first observe the number of this finite sequence: $$\{(1,a_1),(2,a_2),...,(5,a_5)\}$$ which $a_i$ is one of 1 or 2. For the second, we just have the permutations of n element.

Additional info.: When we want to obtain the number of functions from a set $A$ to set $B$, in which $|A|=n$ and $|B|=m$ it's exactly the same, when we want to find the number of all sequences $BOX_1,...,BOX_n$ in which any $BOX_i$ is one of $m$ elements of $B$. yes!the answer obviously is $m.\;\ldots\;.m \qquad(n\; times)$.

Related Question