This algorithm will compute the length of the Collatz sequence for all numbers in a given range. It will then output:
- The number in the provided range with the longest Collatz sequence.
- The biggest number computed while computing the Collatz sequence.
The Collatz sequence is defined as follows:
- If the number is even, divide it by 2.
- If the number is odd, multiply it by 3 and add 1. And you repeat this process until you reach 1. The length of the sequence is the number of steps needed to reach 1.
The Collatz conjecture is the hypothesis that for any number, the Collatz sequence will always reach 1. Technically, the sequence could go on forever for some values, or end up in another cycle, nobody knows.