A Collatz sequence is generated by repeatedly applying the following rules to an integer and then to each resulting integer in turn:
The Collatz conjecture states that, for any initial positive integer, you will eventually reach the number 1.
Write a function that, for an initial positive integer n, returns a list containing 2 values:
collatz(17) ➞ [12, 52]
# Because 17 – 52 – 26 – 13 – 40 – 20 – 10 – 5 – 16 – 8 – 4 – 2 – 1
# takes 12 steps and 52 is the highest number reached.
collatz(6) ➞ [8, 16]
collatz(21) ➞ [7, 64]
N/A