Set A={2,3,5,7,11,13} so |A|=6
Set B={1, 8, 27} so |B|=3
Without any restrictions, each element in A can map to any of the 3 elements in B. Thus, the total number of functions is: $$3^6=729$$
Excluding Functions That Miss One Element in B: If a function does not map to an element in B, there are 2 elements in B left for mapping. The total number of such functions (for each specific element not mapped) is: $$2^6=64$$
Since there are 3 elements in B, the total number of such functions is:3x64=192
Adding Back Functions That Miss Two Elements in B:
If a function misses two elements in B, there is only 1 element left for mapping. The total number of such functions is: 1^6=1.
Since there are $$^3C_2$$ ways to choose which two elements are missed, the total number of such functions is: 3
Using the inclusion-exclusion principle, the number of functions where all elements of B are mapped by at least one element of A is:
729-192+3=540.