# Math Help - [SOLVED] number of onto functions

1. ## [SOLVED] number of onto functions

How many onto functions are there from a set with n elements to a set with three elements?

Could somebody explain how to do this, perhaps substituting 5 in for n?

2. You can solve it by recusive definition: suppose $n\geq 3$
Let $A_n$ be the number of onto function from a set with n elements to a set with three elements, $B_n$ be the number of onto function from a set with n elements to a set with two elements.
then what is the recusive relation between $A_{n+1}$, $A_n$ and $B_n$?
$A_{n+1}=3A_n+3B_n$
while it is easy to see that $A_3=6,B_n=2^n-2$.