3. Determine the natural numbers $p$ and $q$ such that the roots of the trinomials

$$
x^{2}-p x+q \text { and } x^{2}-q x+p
$$

are also natural numbers.
Solution. Let $x_{1}, x_{2}$ be the solutions of the equation $x^{2}-p x+q=0$, and $y_{1}, y_{2}$ be the solutions of the equation $x^{2}-q x+p=0$, such that $x_{1}, x_{2}, y_{1}, y_{2} \in \mathbb{N}$. Then

$$
x_{1}+x_{2}=p, x_{1} x_{2}=q, y_{1}+y_{2}=q, y_{1} y_{2}=p
$$

a) Suppose one of the numbers $x_{1}, x_{2}, y_{1}, y_{2}$ is equal to 1, for example $x_{1}=1$. Then $1+x_{2}=p, x_{2}=q$, so we have

$$
y_{1}+y_{2}-y_{1} y_{2}=q-p=-1, \text{ i.e. }\left(y_{1}-1\right)\left(y_{2}-1\right)=2
$$

Furthermore, it is easy to obtain that $\left\{y_{1}, y_{2}\right\}=\{2,3\}$, i.e., $q=5, p=6, x_{2}=5$.

It is easy to verify that for $p=6, q=5$ the pairs $(1,5)$ and $(5,1)$ are solutions of the equation $x^{2}-6 x+5=0$, and the pairs $(2,3)$ and $(3,2)$ are solutions of the equation $x^{2}-5 x+6=0$. A similar result is obtained for $p=5, q=6$.

b) Suppose $x_{1} \geq 2, x_{2} \geq 2, y_{1} \geq 2, y_{2} \geq 2$. Then

$$
p=x_{1}+x_{2} \leq x_{1} x_{2}=q=y_{1}+y_{2} \leq y_{1} y_{2}=p
$$

from which we get $p=q=x_{1}+x_{2}=x_{1} x_{2}=y_{1}+y_{2}=y_{1} y_{2}$. Suppose, for example, $x_{1} \leq x_{2}$. Then from $x_{1}+x_{2}=x_{1} x_{2} \geq 2 x_{2}$ it follows that $x_{1} \geq x_{2}$. Therefore, $x_{1}=x_{2}$, so $2 x_{1}=x_{1}^{2}$, i.e., $x_{1}=x_{2}=2$. Hence, $p=q=x_{1}+x_{2}=4$. The pair $(2,2)$ is indeed a solution of the equation $x^{2}-4 x+4=0$.

Finally, the pairs $(p, q)$ are $(5,6),(6,5),(4,4)$.