Let
x ----> number of black socks
y ----> number of white socks
we have that
x+y=31 ------> x=31-y -----> equation 1
(1/2)x+(1/3)y=14 -----> equation 2
Solve the system of equations
substitute equation 1 in equation 2
(1/2)(31-y)+(1/3)y=14
solve for y
(31/2)-(1/2)y+(1/3)y=14
(1/2)y-(1/3)y=(31/2)-14
(1/6)y=3/2
y=18/2
y=9
Find out the value of x
x=31-y --------> x=31-9
x=22
therefore
number of black socks: 22
number of white socks: 9