Total number of functions from a set of 4 elements to a set of 3 elements is 34=81.
The number of onto functions is given by the inclusion-exclusion principle:
34−3C124+3C214
=81−3×16+3×1
=81−48+3=36
The number of functions which are not onto is the total number of functions minus the number of onto functions:
81−36=45
Answer: 45