human
Check if all the pairs of an array are coprime with each other | Python3 implementation of the above approach.
Function to check if all the pairs of the array are coprime with each other or not.
Check if GCD of the pair is not equal to 1.
All pairs are non - coprime Return false.
.
Driver code"
How can the above be solved in Python?
 Give me a code to check if all the pairs of an array are coprime with each other and the other steps required?
assistant
#Here is code to check if all the pairs of an array are coprime with each other and the other steps required.
 def gcd ( a , b ) :
	if ( b == 0 ) :
		return a
	else :
		return gcd ( b , a % b )
def allCoprime ( A , n ) :
	all_coprime = True
	for i in range ( n ) :
		for j in range ( i + 1 , n ) :
			if gcd ( A [ i ] , A [ j ] ) != 1 :
				all_coprime = False ;
				break
	return all_coprime
/ * Function return gcd of two number * /
if __name__ == " _ _ main _ _ " :
	A = [ 3 , 5 , 11 , 7 , 19 ]
	arr_size = len ( A )
	if ( allCoprime ( A , arr_size ) ) :
		print ( ' Yes ' )
	else :
		print ( ' No ' )