#Skip to menu

14 - 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.


Source code of the solution(s):