Dear colleagues, such question, it is necessary to divide the number in a column and get an integer result, I wrote the following code, is it optimal? I suspect they won't )

```
private String calculateRemainder(int dividend, int divisor) {
StringBuilder result = new StringBuilder();
char[] dividendDigits = String.valueOf(dividend).toCharArray();
int remainder = 0;
int quotient;
for (char dividendDigit : dividendDigits) {
int iterationDividend = remainder * 10 + getNumericValue(dividendDigit);
quotient = iterationDividend / divisor;
remainder = iterationDividend % divisor;
if (iterationDividend >= divisor || iterationDividend == 0) {
result.append(quotient);
}
}
return result.toString();
}
```

asked June 10th 19 at 16:14

0 answer

Find more questions by tags AlgorithmsJava