M = gw/g+w ... solve for w .... what's the steps I need to solve for w

the way you typed it ....

M = w(1/g + 1)
w = M/(1/g + 1)
or
= M/[(1+g)/g]
= Mg/(1+g)