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 ; if size is even ; if size is odd ; Driver code
function productSumDivisible ( n , size ) { var sum = 0 , product = 1 ; while ( n > 0 ) { if ( size % 2 == 0 ) { product *= n % 10 ; } else { sum += n % 10 ; } n = parseInt ( n / 10 ) ; size -- ; } if ( product % sum == 0 ) return true ; return false ; } var n = 1234 ; var len = 4 ; if ( productSumDivisible ( n , len ) ) document . write ( " " ) ; else document . write ( " " ) ;