Onto functions from an m-element set to an n-element set: n^m − C(n, 1)(n − 1)^m + C(n, 2)(n − 2)^m − C(n, 3)(n − 3)^m + ... (stop at the term with (n − n)). If m < n there are none; if m = n they are the n! bijections.
| Kind of function, |A| = m, |B| = n | Count | Example m = 3, n = 5 |
|---|---|---|
| All functions | n^m | 125 |
| One-one | n(n − 1)...(n − m + 1) | 60 |
| Strictly increasing | C(n, m) | 10 |
| Onto (m < n) | 0 | 0 |
Count onto functions by inclusion-exclusion and check by grouping the elements of A. Remove a forbidden value by subtracting the functions that use it. Use symmetry between the images when one value is fixed. An increasing function is a choice of a subset, so its count is a combination.