915*. Solve the equation in natural numbers

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

The formulas for the unknowns $x, y$, and $z$ that we will obtain have been known in mathematics for over 3000 years (they first appeared in Ancient Babylon). These formulas are useful to know, and the method of solving the problem is instructive.

Equation (1) resembles the Pythagorean theorem. Right triangles with integer sides are called Pythagorean triangles. Therefore, we can rephrase our problem as: find all Pythagorean triangles.
$\triangle$ Let's limit ourselves to the case when the numbers $x, y$, and $z$ are pairwise coprime: if two of these three numbers have a greatest common divisor $d$ greater than 1, then for the equation (1) to have a solution in natural numbers, it is necessary that the third unknown also be divisible by $d$, and then the equality (1) can be divided term by term by $d^{2}$.

Let's think: what can the numbers $x, y$, and $z$ be in terms of parity? Clearly, one of them is even, and two are odd. Which one is even? If $z$ is even, then the right-hand side of the equality is divisible by 4, while the left-hand side is not, so this case is impossible. Therefore, only one of the "legs" can be even, let's say for definiteness it is $x$.

We write the equality (1) as $x^{2}=z^{2}-y^{2}$ and divide the last equality by 4:

$$
\frac{1}{4} x^{2}=\frac{1}{4}\left(z^{2}-y^{2}\right), \quad\left(\frac{x}{2}\right)^{2}=\frac{z+y}{2} \cdot \frac{z-y}{2}
$$

Since the number $x$ is even, and the numbers $z$ and $y$, where $z>y$, are odd, the numbers $\frac{x}{2}, \frac{z+y}{2}$, and $\frac{z-y}{2}$ are natural. Moreover, the numbers $\frac{z+y}{2}$ and $\frac{z-y}{2}$ are coprime, because if they have a greatest common divisor $d$, then by adding and subtracting the relations

$$
\frac{z+y}{2}: d, \quad \frac{z-y}{2}: d,
$$

we get:

$$
z: d, \quad y: d,
$$

which is only possible if $d=1$.

Now let's look at the equality (2): when is the product of two coprime numbers $\frac{z+y}{2}$ and $\frac{z-y}{2}$ equal to the square of a natural number? Only when both these numbers are squares of natural numbers:

$$
\frac{z+y}{2}=a^{2}, \quad \frac{z-y}{2}=b^{2},
$$

where $a$ and $b$ are natural.

To find $z$ and $y$, we add and subtract these equalities:

$$
z=a^{2}+b^{2}, \quad y=a^{2}-b^{2}
$$

Now from the equality (2) we find $x$:

$$
\left(\frac{x}{2}\right)^{2}=a^{2} b^{2}, \quad \frac{x}{2}=a b, \quad x=2 a b
$$

Thus, we have the formulas:

$$
x=2 a b, \quad y=a^{2}-b^{2}, \quad z=a^{2}+b^{2} .
$$

To verify these formulas, substitute the values of $x$ and $y$ into the left-hand side of the equality (1):

$$
x^{2}+y^{2}=4 a^{2} b^{2}+\left(a^{2}-b^{2}\right)^{2}=a^{4}+2 a^{2} b^{2}+b^{4}=\left(a^{2}+b^{2}\right)^{2}=z^{2} \text {. }
$$

We get an identity.

When applying formulas (3) in the case where the numbers $x, y$, and $z$ are pairwise coprime, the following restrictions need to be imposed on the natural numbers $a$ and $b$:

1) $a>b$
2) the numbers $a$ and $b$ are coprime;
3) $a$ and $b$ are of different parity.

(Think about what each of them is due to.)

Let's give examples. For $a=2, b=1$, by formulas (3) we get:

$$
x=2 \cdot 2 \cdot 1=4, \quad y=4-1=3, \quad z=4+1=5 \text {. }
$$

This is a triangle with sides 3, 4, and 5 - the so-called Egyptian triangle.

For $a=3, b=2$, we will have:

$$
x=2 \cdot 3 \cdot 2=12, \quad y=9-4=5, \quad z=9+4=13 \text {. }
$$

Now let's consider that the numbers $x, y$, and $z$ can have a common divisor $k>1$. Then formulas (3) need to be replaced by the following, more general ones:

$$
x=2 a b k, \quad y=\left(a^{2}-b^{2}\right) k, \quad z=\left(a^{2}+b^{2}\right) k .
$$

Here, the natural numbers $a$ and $b$ must satisfy the same restrictions as before, and $k$ is any natural number.

Formulas (4) give the answer to the problem.