0%

Problem 14


Problem 14


Longest Collatz Sequence

The following iterative sequence is defined for the set of positive integers:

nn/2 (n is even)

n3n+1 (n is odd)

Using the rule above and starting with 13, we generate the following sequence:

134020105168421

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.

Which starting number, under one million, produces the longest chain?

NOTE: Once the chain starts the terms are allowed to go above one million.


最长考拉兹序列

考虑如下定义在正整数集上的迭代规则:

nn/2 (若n为偶数)

n3n+1 (若n为奇数)

13开始,可以迭代生成如下的序列:

134020105168421

可以看出这个序列(从13开始到1结束)共有10项。尽管还未被证明,但普遍认为,从任何数开始最终都能抵达1并结束(这被称为“考拉兹猜想”)。

在小于一百万的数中,从哪个数开始迭代生成的序列最长?

注: 在迭代过程中允许出现超过一百万的项。


Gitalking ...