Let the 3 number in the geometric sequence be a/r, a and ar.
The product of the three numbers is a^3 = 512, So a = 8.
Now (a/r) +8, a+6, ar form an AP.
So we have: ar - (a+6) = a+6 - (a/r)-8, or
ar^2-ar-6r = ar+6r-a-8r, or
8r^2–8r-6r = 8r+6r-8–8r, or
8r^2–14r-6r +8 = 0
8r^2–20r+8 = 0, or
2r^2–5r +2= 0, or
(2r-1)(r-2) = 0
Hence r =2 or 1/2.
So the three terms of the GP are 4, 8 and 16 or 16, 8 and 4.
Check: 4+8, 8+6, 16 = 12, 14 16, all in AP. Correct.
16+8, 8+6, 4 = 24, 14, 4, all in AP. Correct