We know the formula for mean is given by

Using the above mentioned formula, the mean of 27 and 5 is given by

Similarly, mean of 8 and x is given by

Now, we have been given that 8 and x have the same mean as 27 and 5. Therefore, we have

Therefore, the x value is 24