about | help | code help+videos | done | prefs |
A Collatz sequence is a sequence of integers starting with n where the next element is n/2 if n is even and 3*n + 1 if n is odd. An unproven conjecture is that the sequence always gets to 1 at some point, regardless of what number it starts with. Write the function collatz(n) that returns the sequence starting with n and ending with 1. collatz(1) → [1] collatz(2) → [2, 1] collatz(3) → [3, 10, 5, 16, 8, 4, 2, 1] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 240 Post-solution available
Copyright Nick Parlante 2017 - privacy