2018-09-30 23:01:58 +01:00
|
|
|
|
---
|
|
|
|
|
id: 5900f4c41000cf542c50ffd6
|
|
|
|
|
title: 'Problem 343: Fractional Sequences'
|
2020-11-27 19:02:05 +01:00
|
|
|
|
challengeType: 5
|
2019-08-05 09:17:33 -07:00
|
|
|
|
forumTopicId: 302002
|
2021-01-13 03:31:00 +01:00
|
|
|
|
dashedName: problem-343-fractional-sequences
|
2018-09-30 23:01:58 +01:00
|
|
|
|
---
|
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --description--
|
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
For any positive integer $k$, a finite sequence $a_i$ of fractions $\frac{x_i}{y_i}$ is defined by:
|
2020-11-27 19:02:05 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
- $a_1 = \displaystyle\frac{1}{k}$ and
|
|
|
|
|
- $a_i = \displaystyle\frac{(x_{i - 1} + 1)}{(y_{i - 1} - 1)}$ reduced to lowest terms for $i > 1$.
|
2020-11-27 19:02:05 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
When $a_i$ reaches some integer $n$, the sequence stops. (That is, when $y_i = 1$.)
|
2020-11-27 19:02:05 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
Define $f(k) = n$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
For example, for $k = 20$:
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
$$\frac{1}{20} → \frac{2}{19} → \frac{3}{18} = \frac{1}{6} → \frac{2}{5} → \frac{3}{4} → \frac{4}{3} → \frac{5}{2} → \frac{6}{1} = 6$$
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
So $f(20) = 6$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
Also $f(1) = 1$, $f(2) = 2$, $f(3) = 1$ and $\sum f(k^3) = 118\\,937$ for $1 ≤ k ≤ 100$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
Find $\sum f(k^3)$ for $1 ≤ k ≤ 2 × {10}^6$.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --hints--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
`fractionalSequences()` should return `269533451410884200`.
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
```js
|
2021-07-29 19:14:22 +02:00
|
|
|
|
assert.strictEqual(fractionalSequences(), 269533451410884200);
|
2018-09-30 23:01:58 +01:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --seed--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
## --seed-contents--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
|
|
```js
|
2021-07-29 19:14:22 +02:00
|
|
|
|
function fractionalSequences() {
|
2020-09-15 09:57:40 -07:00
|
|
|
|
|
2018-09-30 23:01:58 +01:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-29 19:14:22 +02:00
|
|
|
|
fractionalSequences();
|
2018-09-30 23:01:58 +01:00
|
|
|
|
```
|
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
|
# --solutions--
|
2018-09-30 23:01:58 +01:00
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|