def largest_factor_relatively_prime(a, b):
 while 1:
  d = gcd(a, b)
  if (d <= 1):
   break
  b = d
  while 1:
   (q, r) = divmod(a, d)
   if (r > 0):
    break
   a = q
 return a

def largest_factor_relatively_prime ( a , b ) : while 1 : d = gcd ( a , b ) if ( d <= 1 ) : break b = d while 1 : ( q , r ) = divmod ( a , d ) if ( r > 0 ) : break a = q return a
return the largest factor of a relatively prime to b .