3. Find natural numbers $p$ and $q$ such that the roots of the trinomials $x^{2}-p x+q$ and $x^{2}-q x+p$ are natural numbers.
Solution. Let $x_{1}$ and $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$. From Vieta's formulas, we have

$$
\begin{array}{ll}
x_{1}+x_{2}=p, & x_{1} x_{2}=q \\
y_{1}+y_{2}=q, & y_{1} y_{2}=p
\end{array}
$$

We will consider two cases.

Case I. One of the numbers $x_{1}, x_{2}, y_{1}, y_{2}$ is equal to 1. Let this be $x_{1}$. From (1) it follows that $q+1=p$ and by substitution in (2) we get $y_{1}+y_{2}+1=y_{1} y_{2}$, i.e., $\left(y_{1}-1\right)\left(y_{2}-1\right)=2$. Since $y_{1}, y_{2} \in \mathbb{N}$, from the last equation it follows that $y_{1}-1=1$, $y_{2}-1=2$, or $y_{1}-1=2, y_{2}-1=1$. Finally, we find $y_{1}=2, y_{2}=3$, or $y_{1}=3$, $y_{2}=2$, i.e., $p=6, q=5$. Similarly, if $y_{1}=1$, then we get $p=5, q=6$.

Case II. Let $x_{1}, x_{2}, y_{1}, y_{2}>1$. From $x_{1}+x_{2} \leq x_{1} x_{2}$ and $y_{1}+y_{2} \leq y_{1} y_{2}$ we get $p \leq q$ and $q \leq p$, i.e., $p=q$. Since $x_{1}, x_{2}$ are natural numbers, we have $p^{2}-4 p=n^{2}$, from which it follows that $p \geq 4$, and $(p+n-2)(p-n-2)=4$. From $p \geq 4$ we get $p+n-2>0$, and therefore $p-n-2>0$. But, $p+n-2 \geq p-n-2$, so from the last equation we get the systems

$$
\left\{\begin{array} { l } 
{ p + n - 2 = 4 } \\
{ p - n - 2 = 1 }
\end{array} \text { and } \left\{\begin{array}{l}
p+n-2=2 \\
p-n-2=2
\end{array}\right.\right.
$$

The first system has no integer solutions, and from the second we get $p=4, n=0$. Finally, the required numbers are $p=6, q=5 ; p=5, q=6$ and $p=q=4$.