human
Find M such that GCD of M and given number N is maximum | Function to find the integer M such that gcd ( N , M ) is maximum.
Initialize variables.
Find all the divisors of N and return the maximum divisor.
Check if i is divisible by N.
Update max_gcd.
Return the maximum value.
Driver Code.
Given number.
Function call"
How can the above be solved in Python?
assistant
#Here is code to find M such that GCD of M and given number N is maximum and the other steps required.
 def findMaximumGcd ( n ) :
	max_gcd = 1
	i = 1
	while ( i * i <= n ) :
		if n % i == 0 :
			if ( i > max_gcd ) :
				max_gcd = i
			if ( ( n / i != i ) and ( n / i != n ) and ( ( n / i ) > max_gcd ) ) :
				max_gcd = n / i
		i += 1
	return ( int ( max_gcd ) )
if __name__ == ' _ _ main _ _ ' :
	n = 10
	print ( findMaximumGcd ( n ) )