greatest common divisor
两个数如果最大公约数(greatest common divisor)为1我们就称它们为「互质。而要找出最大公约数的方法就是所谓的辗转相除法(Euclidean algorithm):
the “greatest common denominator”
最大公约数(the “greatest common denominator”)
GCD
def is_power(a,b): if a%b==0 and (a/b)%b==0: return True else: return False 求a和b的最大公约数(GCD) def gcd(a, b): if a < b: a, b = b, a while b !
最大公因数,也称最大公约数、最大公因子,指两个或多个整数共有约数中最大的一个。a,b的最大公约数记为(a,b),同样的,a,b,c的最大公约数记为(a,b,c),多个整数的最大公约数也有同样的记号。求最大公约数有多种方法,常见的有质因数分解法、短除法、辗转相除法、更相减损法。与最大公约数相对应的概念是最小公倍数,a,b的最小公倍数记为[a,b]。