Project Euler/14
From charlesreid1
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.