Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

This question already has an answer here:

What is the number of surjective (onto) functions from the set [3] to the set [3].

share|improve this question
add comment

marked as duplicate by Gerry Myerson, Sasha, Paul, Micah, Hagen von Eitzen Feb 9 '13 at 7:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

We first count the complement. There are $2^5$ functions that "miss" $1$, also $2^5$ that miss $2$, and $2^5$ that miss $3$. Add. We get $3\cdot 2^5$.

But we have double-counted the functions that miss both $1$ and $2$, also the functions that miss $2$ and $3$, also the functions that miss $3$ and $1$. There is $1$ (or if you prefer, $1^5$) of each kind, so we subtract $3\cdot 1^5$.

Thus the total number of onto functions is $3^5-3\cdot 2^5+3\cdot 1^5$.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.