Refactor 14 Collatz sequence