Question: > 
> 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.

Answer: 
**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 

1. There are only $3$ functions with range as singletons, for example everything mapping to $a$.
2. 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.
$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](https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle) which even covers this specific problen lower in the page.