human
Check if all the pairs of an array are coprime with each other | Function to store and check the factors.
Check if factors are equal.
Check if the factor is already present.
Insert the factor in set.
Check if the factor is already present.
Insert the factors in set.
Function to check if all the pairs of array elements are coprime with each other.
Check if factors of A [ i ] haven 't occurred previously.
Driver code"
Solution in Python:
assistant
#Here is code to check if all the pairs of an array are coprime with each other and the other steps required.
 def findFactor ( value , factors ) :
	factors . add ( value )
	i = 2
	while ( i * i <= value ) :
	if value % i == 0 :
		if value // i == i :
		if i in factors :
			return bool ( True )
		else :
			factors . add ( i )
		else :
			if ( i in factors ) or
			( ( value // i ) in factors ) :
			return bool ( True )
			else :
			factors . add ( i )
			factors . add ( value // i )
	i += 1
	return bool ( False )
def allCoprime ( A , n ) :
	all_coprime = bool ( True )
	factors = set ( )
	for i in range ( n ) :
		if A [ i ] == 1 :
			continue
		if findFactor ( A [ i ] , factors ) :
		all_coprime = bool ( False )
		break
	return bool ( all_coprime )
A = [ 3 , 5 , 11 , 7 , 19 ]
arr_size = len ( A )
if ( allCoprime ( A , arr_size ) ) :
	print ( " Yes " )
else :
	print ( " No " )