about | help | code help+videos | done | prefs |
In Java, if we begin with an int, divide it by 2, divide the result by 2, divide that result by 2, and so on, we eventually reach 0. For example, if we begin with 19 and repeatedly divide by 2, we get the following numbers: 9, 4, 2, 1, 0. It took 5 divisions to reach 0. Similarly, if we begin with -19 and repeatedly divide by 2, we get: -9, -4, -2, -1, 0. Given int n, determine how many steps it takes to reach 0. stepsToZero(19) → 5 stepsToZero(-19) → 5 stepsToZero(0) → 0 ...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: 200
Copyright Nick Parlante 2017 - privacy