#Skip to menu

Longest Collatz sequence

First read the problem description.

We’ll use memoization to cache results for odd numbers. We don’t cache even numbers since there’s a separate loop that divides even numbers by 2 until we have an odd number. By storing only half of the numbers we also halve the amount of memory needed.

837799

Source code of the solution(s):