let the two numbers be x and y.
Then x + y = 31 ------- (1)
And xy = 150 ---------- (2)
From (1), x = 31 - y
Substitute this expression for x into (2),
(31 - y)y = 150
31y - y^2 = 150
y^2 - 31y + 150 = 0
(y - 6)(y - 25) = 0
Therefore y = 6, y = 25
And x = 31 - 6, x = 31 - 25
i.e. x = 25, y = 6
In other words, the two numbers are just 6 and 25