Equal Sum and XOR of three Numbers | Function to calculate power of 3 ; Function to return the count of the unset bit ( zeros ) ; Check the bit is 0 or not ; Right shifting ( dividing by 2 ) ; Driver Code
function calculate ( bit_cnt ) { let res = 1 ; while ( bit_cnt -- ) { res = res * 3 ; } return res ; } function unset_bit_count ( n ) { let count = 0 ; while ( n ) { if ( ( n & 1 ) == 0 ) count ++ ; n = n >> 1 ; } return count ; } let n ; n = 2 ; let count = unset_bit_count ( n ) ; let ans = calculate ( count ) ; document . write ( ans ) ;