5. In the set of natural numbers, solve the equation

$$
x+y^{2}+(\operatorname{GCD}(x, y))^{2}=x y \cdot \operatorname{GCD}(x, y)
$$
Solution. We introduce the substitution $z=\operatorname{GCD}(x, y)$ and obtain the equation

$$
x+y^{2}+z^{2}=x y z
$$

Let $a$ and $b$ be natural numbers such that

$$
x=a z \text { and } y=b z, \operatorname{GCD}(a, b)=1
$$

Then the equation takes the form

$$
a z+b^{2} z^{2}+z^{2}=a b z^{3}
$$

or

$$
a+b^{2} z+z=a b z^{2}
$$

Since the right side of the last equation is divisible by $z$ and two of the terms on the left side are divisible by $z$, it follows that $z \mid a$. Therefore, there exists a natural number such that $a=c z$. Substituting in the last equation, we get the equation $c z+b^{2} z+z=c b z^{3}$, i.e., the equation $c+b^{2}+1=c b z^{2}$, which is equivalent to the equation

$$
b^{2}+1=c\left(b z^{2}-1\right)
$$

Clearly, $b z^{2} \neq 1$, because otherwise we get $b^{2}+1=0$, which is impossible. Thus, $c=\frac{b^{2}+1}{b z^{2}-1}$ and if we multiply the last equation by $z^{2}$, we get

$$
c z^{2}=\frac{b^{2} z^{2}+z^{2}}{b z^{2}-1}=b+\frac{b+z^{2}}{b z^{2}-1}
$$

Since $c z^{2}$ is a natural number and $\frac{b+z^{2}}{b z^{2}-1}$ is a natural number. Therefore, $b z^{2}-1 \leq b+z^{2}$, i.e.,

$$
\left(z^{2}-1\right)(b-1) \leq 2
$$

If $b=1$, then $c=\frac{2}{z^{2}-1}$, from which it follows that $z^{2}=2$ or $z^{2}=3$, which is impossible. If $b=2$, then $c=\frac{5}{2 z^{2}-1}$. If $2 z^{2}-1=1$, then $z=1$. It follows that $c=5, a=5$, i.e., $x=5$ and $y=2$. If $2 z^{2}-1=5$, then $z^{2}=3$, which is impossible. If $b=3$, then $c=\frac{10}{3 z^{2}-1}$. The cases

$$
3 z^{2}-1=1,3 z^{2}-1=5 \text { and } 3 z^{2}-1=10
$$

are not possible. If $3 z^{2}-1=2$, then $z=1$. It follows that $c=5, a=5$, i.e., $x=5$ and $y=3$. If $b>3$, then from (1) it follows that $z=1$. In the cases

$$
c=\frac{b^{2}+1}{b-1}=b+1+\frac{2}{b-1}
$$

we get $b=2$ or $b=3$, which contradicts $b>3$.

Finally, the solutions to the given equation are $(x, y)=\{(5,2),(5,3)\}$.