Write the formula to find the number of onto functions from set A to set B.

If X has m elements and Y has n elements, the number of onto functions are,

\(n^{m}-{n choose 1}(n-1)^{m} +{ n choose 2}(n-2^{m})……..(-1)^{n-1}{n choose n-1}1^{m}\)

The formula works only

  • If m ≥ n.
  • If m < n, the number of onto functions is 0 as it is not possible to use all elements of Y.