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.

— Rule to remember
Counts to recognise at once
Kind of function, |A| = m, |B| = nCountExample m = 3, n = 5
All functionsn^m125
One-onen(n − 1)...(n − m + 1)60
Strictly increasingC(n, m)10
Onto (m < n)00

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.