human
Count unordered pairs ( i , j ) such that product of a [ i ] and a [ j ] is power of two | Function to check if x is power of 2.
First x in the below expression is for the case when x is 0.
Function to Count unordered pairs.
is a number can be expressed as power of two.
count total number of unordered pairs.
Driver code"
Solution in Python:
 Can you provide a code to count unordered pairs ( i , j ) such that product of a [ i ] and a [ j ] is power of two and the other steps required?
assistant
#Here is code to count unordered pairs ( i , j ) such that product of a [ i ] and a [ j ] is power of two and the other steps required.
 def isPowerOfTwo ( x ) :
	return ( x and ( not ( x & ( x - 1 ) ) ) )
def Count_pairs ( a , n ) :
	count = 0
	for i in range ( n ) :
		if isPowerOfTwo ( a [ i ] ) :
			count += 1
	ans = ( count * ( count - 1 ) ) / 2
	print ( ans )
if __name__ == " _ _ main _ _ " :
	a = [ 2 , 5 , 8 , 16 , 128 ]
	n = len ( a )
	Count_pairs ( a , n )