18. N4 (BUL) Find all positive integers $x$ and $y$ such that $x+y^{2}+z^{3}=x y z$, where $z$ is the greatest common divisor of $x$ and $y$.
18. Let \( x = z a \) and \( y = z b \), where \( a \) and \( b \) are relatively prime. The given Diophantine equation becomes \( a + z b^{2} + z^{2} = z^{2} a b \), so \( a = z c \) for some \( c \in \mathbb{Z} \). We obtain \( c + b^{2} + z = z^{2} c b \), or \( c = \frac{b^{2} + z}{z^{2} b - 1} \). (i) If \( z = 1 \), then \( c = \frac{b^{2} + 1}{b - 1} = b + 1 + \frac{2}{b - 1} \), so \( b = 2 \) or \( b = 3 \). These values yield two solutions: \( (x, y) = (5, 2) \) and \( (x, y) = (5, 3) \). (ii) If \( z = 2 \), then \( 16 c = \frac{16 b^{2} + 32}{4 b - 1} = 4 b + 1 + \frac{33}{4 b - 1} \), so \( b = 1 \) or \( b = 3 \). In this case \( (x, y) = (4, 2) \) or \( (x, y) = (4, 6) \). (iii) Let \( z \geq 3 \). First, we see that \( z^{2} c = \frac{z^{2} b^{2} + z^{3}}{z^{2} b - 1} = b + \frac{b + z^{3}}{z^{2} b - 1} \). Thus \( \frac{b + z^{3}}{z^{2} b - 1} \) must be a positive integer, so \( b + z^{3} \geq z^{2} b - 1 \), which implies \( b \leq \frac{z^{2} - z + 1}{z - 1} \). It follows that \( b \leq z \). But then \( b^{2} + z \leq z^{2} + b2 \). Therefore \( c = \frac{b^{2} + z}{z^{2} b - 1} < 1 \), a contradiction. The only solutions for \( (x, y) \) are \( (4, 2), (4, 6), (5, 2), (5, 3) \).