Let A = {1, 2, 3, 4} and B = {1, 2}. Then, the number of onto functions from A to B is:
Since each element of A can be associated with elements of 8 in two ways, therefore the total number of functions from A to B is 2 × 2 × 2 × 2 = 16. Out of these functions, the functions which are not onto are f (x) = 1, . Thus, the number of onto functions = 16 – 2 = 14.