Python program to Get Find the Greatest Common Divisor

x = int(input("Insert first number: "))
y = int(input("Insert second number: "))
while x != 0 and y != 0:
 if x > y:
  x %= y
 else:
  y &= x
GCD = x + y
print("The greatest common divisor = ",GCD)

 

 

Output:

Insert first number: 12
Insert second number: 48
The greatest common divisor =  12

 

Insert first number: 128
Insert second number: 64
The greatest common divisor =  64

Subscribe For Daily Updates