If you make the two numbers X and Y then we can make a system of equations:
Y - X = 9
X*Y = 162
Using the first equation you can set Y equal to (9 + X) and then plug that in to the second equation
X*(9 + X) = 162
Then if we multiply that out and subtract 162 from both sides we get a quadratic equation
X^2 + 9X - 162 = 0
From here you can just factor to get:
(X + 18)(X - 9) = 0
X = -18, 9
Then when you solve for Y you’re two numbers are either (-18, -9) or (9, 18).