XVIII OM - I - Problem 5

Find such natural numbers $ p $ and $ q $, so that the roots of the equations $ x^2 - qx + p = 0 $ and $ x^2 - px + q = 0 $ are natural numbers.
Let $ x_1 $, $ x_2 $ and $ y_1 $, $ y_2 $ denote the roots of the given equations, respectively. Then the following equalities hold:

From equalities (1) and (2), it follows that

Hence

Since each of the numbers $ x_1-1 $, $ x_2-1 $, $ y_1-1 $, $ y_2-1 $ is $ \geq 0 $, one of the following cases must hold:
a) $ (x_1-1)(x_2-1) = 1,\     (y_1-1)(y_2-1) = 1; $
in this case, $ x_1-1 = x_2-1 = 1 $, so $ x_1 = x_2 = 2 $, and thus $ p = q = 4 $.
b) $ (x_1-1)(x_2-1) = 2,\    (y_1-1)(y_2-1) = 1; $
then $ x_1-1 = 1 $, $ x_2-1 = 2 $ or $ x_1-1 = 2 $, $ x_2-1 = 1 $, i.e., $ x_1 = 2 $, $ x_2 = 3 $ or $ x_1 = 3 $, $ x_2 = 2 $.
Hence $ p = 6 $, $ q = 5 $.
c) $ (x_1-1)(x_2-1) = 0, \    (y_1-1)(y_2-1) = 2; $
similarly to b), we obtain $ y_1 = 2 $, $ y_2 = 3 $ or $ y_1 = 3 $, $ y_2 = 2 $, and thus $ p = 5 $, $ q = 6 $.