about | help | code help+videos | done | prefs |
apcsaLoopsZeroFraction
Given a starting number, a multiple and a divisor, find out how many times you need to repeat the operation x = x * multiple / divisor, using int division meaning truncation is possible, where the first value of x is the starting number, in order for x to reach 0. Preconditions: multiple and divisor are both non-zero, and |divisor| > |multiple| (the divisor will have a larger absolute value than the multiple). HINT: You need to count the number of loops, but don't know how many there will be in advance. What kind of loop structure makes the most sense here?apcsaLoopsZeroFraction(1, 4, 5) → 1 apcsaLoopsZeroFraction(250, 8, 9) → 34 apcsaLoopsZeroFraction(3, -10, 11) → 3 ...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