According to the question it is given that if he purchased 3 medium pizzas, he get 2 side dishes for free.
So, we have to find the number of medium pizza bought to get 8 side dishes free.
Since on buying 3 medium pizzas, we get 2 side dishes free.
On buying 6 medium pizzas, we will get 4 side dishes free.
On buying 9 medium pizzas, we will get 6 side dishes free.
On buying 12 medium pizzas, we will get 8 side dishes free.
Therefore, to get a total of 8 side dishes, we would buy 12 medium pizzas.