about | help | code help+videos | done | prefs |
Given a positive integer, repeatedly apply a step of the Collatz sequence. Each step obeys the following rules: -If the number is even, divide it by 2. -If the number is odd, multiply it by 3 and add 1. Return how many steps it takes to reach the number 1.apcsaLoopsCollatzSequence(1) → 0 apcsaLoopsCollatzSequence(2) → 1 apcsaLoopsCollatzSequence(3) → 7 ...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: 210
Copyright Nick Parlante 2017 - privacy