I have reviewed your code and here are my analysis-
use modulo operator(%) to get the remainder in place of using too much mathematics like
long remainder = num - (quotient * 10); //note: it will just shorten your code
// but will be overhead as well because internally it will
//perform three operation(multiplication, subtraction, division).
// C = A % B is equivalent to C = A – B * (A / B).
could be simplifysimplified to
long remainder = num % 10;
You don't need an extra method to count divisor it can be done in athe same method it selfitself.
You can merge the both method while extracting the digit itself can check whether itsit's a divisor or not?
static int findDigits(int n) {
int count = 0;
int num = n;
while (n > 0) {
int r = n % 10; // to get the remainder
if (r != 0 && num % r == 0) // checking for the divisor
count++;
n = n / 10; // using to remove last digit
}
return count;
}
Note: if still need more explanation about the code then click here.