Traveersing the string
for ( int i = 0 ; i < num . length ( ) ; i ++ ) { if ( i % 2 != 0 ) { product = product * Character . getNumericValue ( num . charAt ( i ) ) ; } else { sum = sum + Character . getNumericValue ( num . charAt ( i ) ) ; } } if ( product % sum == 0 ) { return true ; } else { return false ; } }