4. Determine all pairs of integers $(x, y)$ for which $2 x y$ is a square and $x^{2}+y^{2}$ is a prime number.
## 4. Version for Grade 5 & Grade 6

We have $2xy = a^2$ with $a$ a non-negative integer and $x^2 + y^2 = p$ with $p$ a prime number.

Since a prime number cannot be a square, it follows that $x, y \neq 0$. Because $2xy$ is a square, it follows that $x$ and $y$ are both positive or both negative. If $(x, y)$ is a solution, then $(-x, -y)$ is also a solution, so we may assume in the following that $x$ and $y$ are positive and add the solution $(-x, -y)$ at the end for each found solution $(x, y)$.

Combining $2xy = a^2$ and $x^2 + y^2 = p$ gives $(x+y)^2 = x^2 + y^2 + 2xy = p + a^2$. By moving $a^2$ to the other side, we find

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

Since $x+y+a$ is positive, $x+y-a$ must also be positive. The prime number $p$ can only be written as a product of two positive integers in two ways: $1 \cdot p$ and $p \cdot 1$. Since $x+y+a \geq x+y-a$, it follows that $x+y+a = p$ and $x+y-a = 1$.

If we add these two equations, we find that $2x + 2y = p + 1$. We also know that $x^2 + y^2 + 1 = p + 1$, so $2x + 2y = x^2 + y^2 + 1$. By moving all terms to the right side and adding 1 to both sides, we get

$$
1 = x^2 + y^2 - 2x - 2y + 2 = (x-1)^2 + (y-1)^2.
$$

We now have two integer squares that add up to 1. This can only happen if one of the squares is 0 and the other is 1, so $(x-1)^2 = 0$ and $(y-1)^2 = 1$, or $(x-1)^2 = 1$ and $(y-1)^2 = 0$. Since $x$ and $y$ are positive, we find two possible solutions: $x = 1$ and $y = 2$, or $x = 2$ and $y = 1$. In both cases, $2xy = 4$ is a square and $x^2 + y^2 = 5$ is a prime number. Both possibilities are indeed solutions.

Adding the solutions where $x$ and $y$ are negative gives a total of four solutions $(x, y)$, namely

$$
(1, 2), (2, 1), (-1, -2), (-2, -1)
$$