Check whether product of digits at even places is divisible by sum of digits at odd place of a number | Below function checks whether product of digits at even places is divisible by sum of digits at odd places ; Converting integer to string ; Traveersing the string ; Driver code
function productSumDivisible ( n ) { var sum = 0 var product = 1 var num = n . toString ( ) ; for ( i = 0 ; i < num . length ; i ++ ) { if ( i % 2 != 0 ) { product = product * Number ( num [ i ] ) } else { sum = sum + Number ( num [ i ] ) } } if ( product % sum == 0 ) { return true ; } else { return false ; } } var n = 1234 if ( productSumDivisible ( n ) ) { document . write ( " " ) } else { document . write ( " " ) }