id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com apcsa-loops > apcsaLoopsZeroFraction
prev  |  next  |  chance

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)

public int apcsaLoopsZeroFraction(int start, int multiple, int divisor) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 210

Copyright Nick Parlante 2017 - privacy