Mean of the set of four numbers:
(x1 + x2 + x3 + x4)/4 = 18
Multiply both sides by 4, so
x1 + x2 + x3 + x4 = 4*18 ...(1)
Mean of the five numbers
(x1 + x2 + x3 + x4 + x5)/5 = 16
Multiply both sides by 5, so
x1 + x2 + x3 + x4 + x5 = 5*16 ...(2)
Replace x1 + x2 + x3 + x4 in (2) by using (1)
4*18 + x5 = 5*16
Subtract 4*18 from both sides
x5 = 5*16 - 4*18
x5 = 80 - 72
x5 = 8