Find the number of functions from a 5-element set onto a 3-element set 
In class we learned the number of functions from an $m$-element set to an $n$-element set is $n^{m}$. So this answer should be $5^{3}$? 

I just need confirmation if my answer is correct, if not explain to me why it's not.
 A: hint
From the total number of functions $3^5$ subtract the number of functions which are NOT onto. Suppose your target set is $\{a,b,c\}$. Then 


*

*There are only $3$ functions with range as singletons, for example everything mapping to $a$.

*Now count the number of functions whose range is of the form $\{a,b\}$. This will be $3(2^5-2)=90$ (Think why?).


In general, inclusion-exclusion principle is used for such problems.
A: Let $F$ denote the set of all functions $\{1,2,3,4,5\}\to\{1,2,3\}$. 
For $i=1,2,3$ let $F_i\subset F$ denote the functions in $F$ that have not $i$ in their image. 
Then you are looking for: $$|F|-|F_1\cup F_2\cup F_3|=3^5-|F_1\cup F_2\cup F_3|$$
Term $|F_1\cup F_2\cup F_3|$ can be found by means of inclusion/exclusion combined with symmetry:$$|F_1\cup F_2\cup F_3|=\binom31|F_1|-\binom32|F_1\cap F_2|=3\cdot2^5-3\cdot1^5$$
A: Let $S_j$ be all the functions from $\{1,2,3,4,5\}$ to $\{1,2,3\}$ that miss $j$, for $j\in\{1,2,3\}$
$$
N_k=\sum_{|A|=k}\left|\,\bigcap_{j\in A} S_j\,\right|
$$
Note that $\bigcap\limits_{j\in A} S_j$ is the set of functions from $\{1,2,3,4,5\}$ to $\{1,2,3\}\setminus A$.
There are $\binom{3}{k}$ ways to choose $A$.
For each choice of $A$, there are $(3-k)^5$ functions in $\bigcap\limits_{j\in A} S_j$.
Therefore, $N_k=\binom{3}{k}(3-k)^5$. Using the Generalized Principle of Inclusion-Exclusion, there are
$$
\sum_{k=0}^3(-1)^k\binom{k}{0}\binom{3}{k}(3-k)^5=150
$$
functions in none of the $S_j$.
A: First split $[5]$ into $3$ nonempty blocks, then assign values from $[3]$ to these blocks in $3!=6$ ways. The number of splittings is the Stirling number of the second kind $S(5,3)$. It is obtained as follows:
The blocks can have sizes (a) $3,1,1$ or (b) $2,2,1$. In case (a) the large block can be formed in ${5\choose 3}=10$ ways. In case (b) the singleton can be chosen in $5$ ways, and the remaining four elements can then be paired in $3$ ways, makes $15$ splittings. 
It follows that $S(5,3)=25$, so that there are $25\cdot6=150$ surjective mappings $f:\>[5]\to[3]$.
A: $n^m$ counts all functions from $m$ to $n$, but you want only the onto ones, so all values in the image should occur at least once, this forces $n \le m$ of course (every $i \in m$ has at least one $j \in m$ mapping to it, and different $i$'s have different $j$'s)
A hint as to how to count them: inclusion-exclusion with the properties $P_i: i \notin \operatorname{Im}(f)$. See wikipedia which even covers this specific problen lower in the page.
A: When talking about functions, the word 'onto', which you used in the title of the question, has a specific technical meaning (it means the function is 'surjective'). If this is what you meant then the other responses give the answer.
If you were just using 'onto' to mean the same as 'to', then the only problem with your answer is that you swapped the roles of $n$ and $m$, so the answer should be $3^5$. (You can see this, as each of the five elements has a choice of three things the function can send it to, so there are $3\times 3\times 3\times 3\times 3$ possible choices.)
