Solution
Counting Surjections
Show the problem again
How many functions from a 5-element set to a 3-element set are surjective (hit every element of the codomain)?
Worked solution
The answer is 150. By inclusion-exclusion on which codomain elements are missed: 3⁵ − C(3,1)·2⁵ + C(3,2)·1⁵ = 243 − 96 + 3 = 150. Equivalently, S(5,3) · 3! = 25 · 6 = 150 using Stirling numbers of the second kind.
Source: Standard inclusion-exclusion exercise from introductory combinatorics texts. Statement written for AxiomIQ.