Write a python function that returns the gcd of two numbers


Topic: Write a python function that returns the gcd of two numbers

Solution

def gcd(x, y):
   if x > y:
      smaller = y
   else:
      smaller = x
   for i in range(1, smaller + 1):
      if((x % i == 0) and (y % i == 0)):
         gcd = i
   
   return gcd



List all Python Programs