2021-06-15 00:49:18 -07:00
---
id: 5900f51d1000cf542c51002f
2021-11-29 08:32:04 -08:00
title: 'Problema 433: Etapas no algoritmo de Euclides'
2021-06-15 00:49:18 -07:00
challengeType: 5
forumTopicId: 302104
dashedName: problem-433-steps-in-euclids-algorithm
---
# --description--
2021-11-29 08:32:04 -08:00
Considere $E(x_0, y_0)$ como o número de etapas necessárias para determinar o máximo divisor comum de $x_0$ e $y_0$ com o algoritmo de Euclides. Mais formalmente:
2021-06-15 00:49:18 -07:00
2022-04-05 23:36:59 +05:30
$$\begin{align} & x_1 = y_0, y_1 = x_0\bmod y_0 \\\\
& x_n = y_{n - 1}, y_n = x_{n - 1}\bmod y_{n - 1} \end{align}$$
2021-06-15 00:49:18 -07:00
2021-11-29 08:32:04 -08:00
$E(x_0, y_0)$ é o menor $n$, tal que $y_n = 0$.
2021-06-15 00:49:18 -07:00
2021-11-29 08:32:04 -08:00
Temos $E(1, 1) = 1$, $E(10, 6) = 3$ e $E(6, 10) = 4$.
2021-06-15 00:49:18 -07:00
2021-11-29 08:32:04 -08:00
Defina $S(N)$ como a soma de $E(x, y)$ para $1 ≤ x$, $y ≤ N$.
Temos $S(1) = 1$, $S(10) = 221$ e $S(100) = 39.826$.
Encontre $S(5 \times {10}^6)$.
2021-06-15 00:49:18 -07:00
# --hints--
2021-11-29 08:32:04 -08:00
`stepsInEuclidsAlgorithm()` deve retornar `326624372659664` .
2021-06-15 00:49:18 -07:00
```js
2021-11-29 08:32:04 -08:00
assert.strictEqual(stepsInEuclidsAlgorithm(), 326624372659664);
2021-06-15 00:49:18 -07:00
```
# --seed--
## --seed-contents--
```js
2021-11-29 08:32:04 -08:00
function stepsInEuclidsAlgorithm() {
2021-06-15 00:49:18 -07:00
return true;
}
2021-11-29 08:32:04 -08:00
stepsInEuclidsAlgorithm();
2021-06-15 00:49:18 -07:00
```
# --solutions--
```js
// solution required
```