Problem 14 » 履歴 » バージョン 1
Noppi, 2023/12/30 11:54
| 1 | 1 | Noppi | [ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] |
|---|---|---|---|
| 2 | # [[Problem 14]] |
||
| 3 | |||
| 4 | ## Longest Collatz Sequence |
||
| 5 | The following iterative sequence is defined for the set of positive integers: |
||
| 6 | |||
| 7 | * $n \to n/2$ ($n$ is even) |
||
| 8 | * $n \to 3n + 1$ ($n$ is odd) |
||
| 9 | |||
| 10 | Using the rule above and starting with $13$, we generate the following sequence: |
||
| 11 | $$13 \to 40 \to 20 \to 10 \to 5 \to 16 \to 8 \to 4 \to 2 \to 1.$$ |
||
| 12 | It can be seen that this sequence (starting at $13$ and finishing at $1$) contains $10$ terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at $1$. |
||
| 13 | Which starting number, under one million, produces the longest chain? |
||
| 14 | **NOTE:** Once the chain starts the terms are allowed to go above one million. |
||
| 15 | |||
| 16 | ## 最長のコラッツ数列 |
||
| 17 | 正の整数に以下の式で繰り返し生成する数列を定義する. |
||
| 18 | |||
| 19 | * n → n/2 (n が偶数) |
||
| 20 | * n → 3n + 1 (n が奇数) |
||
| 21 | |||
| 22 | 13からはじめるとこの数列は以下のようになる. |
||
| 23 | $$13 \to 40 \to 20 \to 10 \to 5 \to 16 \to 8 \to 4 \to 2 \to 1.$$ |
||
| 24 | 13から1まで10個の項になる. この数列はどのような数字からはじめても最終的には 1 になると考えられているが, まだそのことは証明されていない(コラッツ問題) |
||
| 25 | さて, 100万未満の数字の中でどの数字からはじめれば最長の数列を生成するか. |
||
| 26 | **注意:** 数列の途中で100万以上になってもよい |
||
| 27 | |||
| 28 | ```scheme |
||
| 29 | ``` |