First, the numbers.
24 = 2 * 2 * 2 * 3
18 = 2 * 3 * 3
We need a pool of prime factors that can make either 24 or 18. 2 * 2 * 2 * 3 * 3 = 72 has enough 2's and 3's to make either 24 or 18.
x^3 = x * x * x
x^2 = x * x
x^3 is the smallest thing that x^3 and x^2 will go into.
y = y
y^2 = y * y
y^2 is the smallest thing that y and y^2 will go into.
Answer: 72 x^3 y^2