X = Y+5Z is 6 years older than X.
Z = X+6...the sum of their ages is 31...
X+Y+Z = 31 First substitute (Y+5) for X in Z = X+6 and simplify. Then substitute (Y+5) for X and Z = (what you got) into X+Y+Z = 31 and solve for Y. Then substitute that value for Y in X = Y+5 to find X. Then substitute what you got for X in Z = X+6 to find Z. I won't tell you the answers but one of them is twice as old as another of them. Edwin
Let "y" is the age of the person Y. Then the age of X is (y+5), and the age of Z is (y+5)+6, according to the condition. The sum of ages is y + (y+5) + ((y+5)+6) = 3y + 16, and it is equal to 31. So you have this equation 3y + 16 = 31. Solve it for "y" and get the answer. Should I explain more or you just can to complete it yourself?