GCD using euclids algorithms & looping

# Credits to NPTEL MOOC,Programming, Data Structures & Algorithms 
#in Python by Madhavan Mukund, Chennai Mathematical Institute

def gcd(m,n):
  if m < n:  # Assume m >= n
    (m,n) = (n,m)
  while (m%n) != 0:
    diff = m-n
    # diff > n? Possible!
    (m,n) = (max(n,diff),min(n,diff))
  return(n)

No comments: