human
Write me a code to largest subsequence having GCD greater than 1 and the other steps required given the following:
Largest subsequence having GCD greater than 1 | Returns length of the largest subsequence with GCD more than 1..
Finding the Maximum value in arr [ ].
Iterate from 2 to maximum possible divisor of all give values.
If we found divisor , increment count.
Driver code"
Solution in Python:
assistant
#Here is code to largest subsequence having GCD greater than 1 and the other steps required.
 def largestGCDSubsequence ( arr , n ) :
	ans = 0
	maxele = max ( arr )
	for i in range ( 2 , maxele + 1 ) :
		count = 0
		for j in range ( n ) :
			if ( arr [ j ] % i == 0 ) :
				count += 1
		ans = max ( ans , count )
	return ans
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 6 , 2 , 5 , 4 ]
	size = len ( arr )
	print ( largestGCDSubsequence ( arr , size ) )