两个或多个整数的最高公因数或最大公除数是将数均匀除而无余数的最大正整数。例如,GCD 8和12为4。
x = int(input("Enter first number: ")) y = int(input("Enter second number: ")) if x > y: smaller = y else: smaller = x for i in range(1,smaller + 1): if((x % i == 0) and (y % i == 0)): hcf = i print("The H.C.F. of", x,"and", x,"is", hcf)