Given:
Number of elements in A = 5
Number of elements in B = 2
Each Element of A have 2 options to form an image.
Thus, Total number of functions that can be formed = 2 × 2 × 2 × 2 × 2 = 32
Number of functions having only one image i.e., {x} = 1
Number of functions having only one image i.e., {y} = 1
Thus, Number of onto functions that can be formed = 32 − 1 − 1 = 30
​Hence, the total number of onto functions from the set A = {1, 2, 3, 4, 5} to the set B = {x, y} is 30.