human
Count pairs whose products exist in array | Returns count of pairs whose product exists in arr [ ].
find product in an array.
if product found increment counter.
return Count of all pair whose product exist in array.
Driver program"
How can the above be solved in Python?
 Give me a code to count pairs whose products exist in array and the other steps required?
assistant
#Here is code to count pairs whose products exist in array and the other steps required.
 def countPairs ( arr , n ) :
	result = 0 ;
	for i in range ( 0 , n ) :
		for j in range ( i + 1 , n ) :
			product = arr [ i ] * arr [ j ] ;
			for k in range ( 0 , n ) :
				if ( arr [ k ] == product ) :
					result = result + 1 ;
					break ;
	return result ;
arr = [ 6 , 2 , 4 , 12 , 5 , 3 ] ;
n = len ( arr ) ;
print ( countPairs ( arr , n ) ) ;