Problem link: https://projecteuler.net/problem=14
The Collatz sequence, also called a hailstone sequence, is a sequence of numbers determined by two formulas, applied depending on whether the current number in the sequence is even or odd. If a given term in the sequence is odd, the next term is computed using the expression
and if it is even, the following formula is used:
Eventually, this sequence will begin to repeat. The task for this problem is to compute a Collatz sequence for all of the integers under 1 million, and determine which starting integer leads to the longest Collatz sequence.
As you can probably imagine, the integers in this problem get really big. I initially began with longs, but when I had finished the implementation and began to run the program, I realized I needed to use BigInteger in my implementation.
Project Eulerproject euler notes
Round 1: Problems 1-20
Round 2: Problems 50-70
Round 3: Problems 100-110
Round 4: Problems 500-510
Round 5: Problems 150-160
Round 6: Problems 250-260
Round 7: Problems 170-180