Problem
COM-B2-M02-P019 All Boxes Nonempty
#19
★★★★★ Level 5 of 5
How many ways are there to distribute \(n\) distinct balls among \(m\) distinct boxes so that every box is nonempty? Derive a formula.
This is the same as an onto function from balls to boxes.
Each distribution is a function from the set of balls to the set of boxes. Requiring every box to be nonempty means the function is onto. By inclusion-exclusion, the number is
\[\sum_{i=0}^{m}(-1)^i\binom mi(m-i)^n.\]
Here \(i\) is the number of chosen boxes declared empty.
Connects the language of functions and distributions.