human
What is a code to number of pairs such that their HCF and LCM is equal and the other steps required given the following:
Number of pairs such that their HCF and LCM is equal | Function to return HCF of two numbers.
Function to return LCM of two numbers.
Returns the number of valid pairs.
Traversing the array . For each array element , checking if it follow the condition.
Driver function"
Solution in Python:
assistant
#Here is code to number of pairs such that their HCF and LCM is equal and the other steps required.
 def gcd ( a , b ) :
	if ( a == 0 ) :
		return b ;
	return gcd ( b % a , a ) ;
def lcm ( a , b ) :
	return ( a * b ) / gcd ( a , b ) ;
def countPairs ( arr , n ) :
	for i in range ( n ) :
		for j in range ( i + 1 , n ) :
			if ( lcm ( arr [ i ] , arr [ j ] ) == gcd ( arr [ i ] , arr [ j ] ) ) :
				ans += 1 ;
	return ans ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 1 , 1 ] ;
	n = len ( arr ) ;
	print ( countPairs ( arr , n ) ) ;