about | help | code help+videos | done | prefs |
Collatz number is defined as the number of steps it takes to reduce a number to 1 using the following steps: 1. if the number is even, divide it be 2. 2. if the number is odd, multiply it by 3 and add 1 to it. Define a function that when passed an integer, returns its collatz number. You may assume the number is 1 or more. collatz(1) → 0 collatz(20) → 7 collatz(100) → 25 ...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: 3 Post-solution available
Copyright Nick Parlante 2017 - privacy