int candles(int candlesNumber, int makeNew) { var sum = candlesNumber; while (candlesNumber >= makeNew) { sum += candlesNumber / makeNew; candlesNumber = candlesNumber / makeNew + (candlesNumber - candlesNumber / makeNew * makeNew); } return sum; }
Previous Next