$A=\{1,2,3,4,5\}$, $B=\{1,2\}$ How many functions $f:A\rightarrow B$ exists 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!
 A: 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)$.
A: The set of functions from $A$ to $B$ is sometimes denoted by $B^A$ and this notation is to emphasize the fact that in finite cardinality case we have
$$\mathrm{card}(B^A)=\mathrm{card}(B)^{\mathrm{card}(A)}$$
Can we find an injective function from $A$ to $B$? Compare the cardinals of $A$ and $B$.
The cardinal of the bijections on the finite set $A$ is $\left(\mathrm{card}(A)\right)!$
A: The only condition for f to be a function from A to B is that there must exist f(x) belonging to B. There are only 5 possible values for x and only 2 for f(x) so the answer is $2^5$. 
