Check whether product of digits at even places of a number is divisible by K | below function checks whether product of digits at even places is divisible by K ; if position is even ; Driver code
function productDivisible ( n , k ) { var product = 1 , position = 1 ; while ( n > 0 ) { if ( position % 2 == 0 ) product *= n % 10 ; n = parseInt ( n / 10 ) ; position ++ ; } if ( product % k == 0 ) return true ; return false ; } var n = 321922 ; var k = 3 ; if ( productDivisible ( n , k ) ) document . write ( " " ) ; else document . write ( " " ) ;