Greatest common divisor program with looping

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


def gcd(m,n):
  i = min(m,n)
  while i > 0:
    if (m%i) == 0 and (n%i) == 0:
      return(i)
    else:
      i = i-1

No comments: