
4. Determine all pairs of integers $(x, y)$ such that $2 x y$ is a perfect square and $x^{2}+y^{2}$ is a prime number.
## 4. Version for klas $4 \&$ below

We may assume that $a \geqslant 0$. If $(x, y)$ is a solution, then $(-x,-y)$ is a solution as well. Therefore, we may for now assume that $x+y \geqslant 0$ and, at the end, add for each solution $(x, y)$ the pair $(-x,-y)$ to the list of solutions.

We see that

$$
p=(x+y)^{2}-a^{2}=(x+y+a)(x+y-a) .
$$

It follows that $x+y+a$ is non-zero, and hence positive. Then $x+y-a$ must be positive as well. The prime number $p$ can be written as a product of two positive integers in only two ways: $1 \cdot p$ and $p \cdot 1$. Since $x+y+a \geqslant x+y-a$, we must have $x+y+a=p$ and $x+y-a=1$. Adding these two equations, we obtain $2 x+2 y=p+1$. We also know that $x^{2}+y^{2}+1=p+1$, so we obtain $2 x+2 y=x^{2}+y^{2}+1$. By bringing all terms to the right-hand side and adding 1 to both sides, we find

$$
1=x^{2}+y^{2}-2 x-2 y+2=(x-1)^{2}+(y-1)^{2} \text {. }
$$

We now have two perfect squares that add up to 1 . This means that one of the squares is equal to 1 and the other is equal to 0 . Hence, $(x-1)^{2}=0$ and $(y-1)^{2}=1$, or $(x-1)^{2}=1$ and $(y-1)^{2}=0$. In the first case we have $x-1=0$ and $y-1= \pm 1$, so $(x, y)$ is equal to $(1,2)$ or $(1,0)$. In the second case we have $x-1= \pm 1$ and $y-1=0$, so $(x, y)$ is equal to $(2,1)$ or $(0,1)$. Since $0^{2}+1^{2}=1$ is not a prime number, $(1,0)$ and $(0,1)$ are eliminated as candidate solutions.

We now check whether $(1,2)$ and $(2,1)$ are solutions. In both cases we find $p=x^{2}+y^{2}=1^{2}+2^{2}=5$, which is a prime number as required. Taking $a=2$, we have $(x+y)^{2}-a^{2}=3^{2}-2^{2}=5$, which is indeed equal to $p$.

Adding the solutions obtained by replacing $(x, y)$ by $(-x,-y)$, we find a total of four solutions, namely

$$
(1,2),(2,1),(-1,-2),(-2,-1) \text {. }
$$

