主题
Search

最大公约数


最大公约数,有时也称为最高公约数 (Hardy and Wright 1979, p. 20),是两个正整数 ab 最大的共同约数,即 ab 都能被它整除。例如,GCD(3,5)=1GCD(12,60)=12,和 GCD(12,90)=6。最大公约数 GCD(a,b,c,...) 也可以定义为三个或更多正整数的最大公约数,即它们共有的最大约数。最大公约数为 1 的两个或多个正整数被称为彼此互质,通常简称为“互质”。

各种符号约定总结在下表中。

符号来源
GCD(a,b)本作品,Zwillinger (1996, p. 91), Råde and Westergren (2004, p. 54)
gcd(a,b)Gellert et al. (1989, p. 25), D'Angelo and West (1990, p. 13), Graham et al. (1990, p. 103), Bressoud and Wagon (2000, p. 7), Yan (2002, p. 30), Bronshtein et al. (2007, pp. 323-324), Wolfram Language
g.c.d.(a,b)Andrews 1994, p. 22
(a,b)

a, b, ... 的最大公约数在 Wolfram Language 中实现为GCD[a, b, ...].

GreatestCommonDivisor

上图显示了 GCD(1,b) 与有理数 b=m/n 的关系。这里,GCD(r_1,r_2,...) 是最大的有理数 r,对于它,所有的 r_i/r 都是整数。很容易看出,如果 r_i=p_i/q_i,其中 GCD(p_i,q_i)=1,那么 GCD(r_1,r_2,...)=GCD(p_1,p_2,...)/LCM(q_1,q_2,...)。此外,如果通过将 GCD(1,b) 扩展为当 b 是无理数时,其值等于 0,则得到的函数在无理数处连续,在有理数处不连续,并且在任何有限区间上的黎曼积分等于 0。

GCDArray

以上图表显示了 GCD(i,j)(i,j)-平面中的一些可视化表示。左图是简单的 GCD(i,j),中间的图是 GCD(i,j) 的二维离散傅里叶变换的绝对值 (Trott 2004, pp. 25-26),右图是 1/GCD(i,j) 变换的绝对值。

如果 dab 的最大公约数,那么 d 是满足以下条件的最大可能整数

a=dx
(1)
b=dy,
(2)

其中 xy 是正整数。

欧几里得算法可以用来求两个整数的最大公约数,并找到整数 xy 使得

 ax+by=d.
(3)

这个概念也可以推广到比整数 Z 更一般的。然而,即使对于欧几里得环,两个环元素的 GCD 的概念与环的两个理想的 GCD 概念也不同。当研究除 Z 以外的环(例如多个变量的多项式环)时,这有时会成为混淆的来源。

为了计算 GCD,写出 ab素因数分解

a=product_(i)p_i^(alpha_i)
(4)
b=product_(i)p_i^(beta_i),
(5)

其中 p_is 是 ab 的所有素因子,并且如果 p_i 没有在一个因式分解中出现,则相应的指数取为 0。那么最大公约数 GCD(a,b) 由下式给出

 GCD(a,b)=product_(i)p_i^(min(alpha_i,beta_i)),
(6)

其中 min 表示最小值。例如,考虑 GCD(12,30)

12=2^2·3^1·5^0
(7)
30=2^1·3^1·5^1,
(8)

所以

 GCD(12,30)=2^1·3^1·5^0=6.
(9)

GCD 是可分配的

 GCD(ma,mb)=mGCD(a,b)
(10)
 GCD(ma,mb,mc)=mGCD(a,b,c),
(11)

且是结合性的

GCD(a,b,c)=GCD(GCD(a,b),c)
(12)
=GCD(a,GCD(b,c))
(13)
GCD(ab,cd)=GCD(a,c)GCD(b,d)×GCD(a/(GCD(a,c)),d/(GCD(b,d)))×GCD(c/(GCD(a,c)),b/(GCD(b,d))).
(14)

如果 a=a_1GCD(a,b)b=b_1GCD(a,b),则

GCD(a,b)=GCD(a_1GCD(a,b),b_1GCD(a,b))
(15)
=GCD(a,b)GCD(a_1,b_1),
(16)

所以 GCD(a_1,b_1)=1。GCD 也是幂等的

 GCD(a,a)=a,
(17)

交换律

 GCD(a,b)=GCD(b,a),
(18)

并满足吸收律

 LCM(a,GCD(a,b))=a.
(19)
GCDRecurrence

对于正奇数 ab,收敛到 GCD(a,b) 的递归方程由下式给出

 x_n=(x_(n-1)+x_(n-2))/(2^(gde(x_(n-1)+x_(n-2),2)))
(20)

其中 x_1=ax_2=b,其中 gde(n,b)bn 中的最大整除指数 (Stehlé and Zimmerman 2004)。上图显示了奇数 1<=a,b<=199 收敛所需的迭代次数。

随机选择的两个整数互质的概率为 [zeta(2)]^(-1)=6/pi^2,其中 zeta(z)黎曼 zeta 函数。Polezzi (1997) 观察到 GCD(m,n)=k,其中 k平面上连接向量 (0, 0) 和 (m,n) 的直线上的格点数(不包括 (m,n) 本身)。这个观察结果与获得互质整数的概率密切相关,也与既约分数 y/x 的几何解释有关,即作为穿过格点的字符串,端点为 (1,0) 和 (x,y)。它压在 (x_i,y_i) 上的钉子给出了 y_i/x_i 的交替收敛项,是 y/x连分数,而其他收敛项是从它压在钉子上获得的,初始端点为 (0, 1)。

Knuth 证明了

 GCD(2^p-1,2^q-1)=2^(GCD(p,q))-1.
(21)

另请参阅

Bézout 数, Bézout 定理, 狄利克雷函数, 欧几里得果园, 欧几里得算法, 扩展最大公约数, 高斯引理, 最大公约数定理, 半 GCD, 最小公倍数, 最小素因子, 果园种植问题, 互质, 大卫之星定理 在 MathWorld 课堂中探索此主题

相关 Wolfram 网站

http://functions.wolfram.com/IntegerFunctions/GCD/

使用 Wolfram|Alpha 探索

参考文献

Andrews, G. E. Number Theory. New York: Dover, 1994.Bressoud, D. M. and Wagon, S. A Course in Computational Number Theory. London: Springer-Verlag, 2000.Bronshtein, I. N.; Semendyayev, K. A.; Musiol, G.; and Muehlig, H. Handbook of Mathematics, 5th ed. Berlin: Springer-Verlag, 2007.D'Angelo, J. P. and West, D. B. Mathematical Thinking: Problem-Solving and Proofs, 2nd ed. Upper Saddle River, NJ: Prentice-Hall, 2000.Gellert, W.; Gottwald, S.; Hellwich, M.; Kästner, H.; and Künstner, H. (Eds.). VNR Concise Encyclopedia of Mathematics, 2nd ed. New York: Van Nostrand Reinhold, 1989.Graham, R. L.; Knuth, D. E.; and Patashnik, O. Concrete Mathematics: A Foundation for Computer Science. Reading, MA: Addison-Wesley, 1990.Nagell, T. "Least Common Multiple and Greatest Common Divisor." §5 in Introduction to Number Theory. New York: Wiley, pp. 16-19, 1951.Polezzi, M. "A Geometrical Method for Finding an Explicit Formula for the Greatest Common Divisor." Amer. Math. Monthly 104, 445-446, 1997.Råde, L. and Westergren, B. Mathematics Handbook for Science and Engineering. Berlin: Springer-Verlag, 2004.Séroul, R. "The Greatest Common Divisor." §2.4 in Programming for Mathematicians. Berlin: Springer-Verlag, pp. 9-11, 2000.Stehlé, D. and Zimmerman, P. "A Binary Recursive GCD Algorithm." In Algorithmic Number Theory. Proceedings of the 6th International Symposium (ANTS-VI) held at the University of Vermont, Burlington, VT, June 13-18, 2004 (Ed. D. Buell). Berlin: Springer-Verlag, pp. 411-425, 2004.Trott, M. The Mathematica GuideBook for Programming. New York: Springer-Verlag, pp. 25-26, 2004. http://www.mathematicaguidebooks.org/.Yan, S. Y. Number Theory for Computing, 2nd ed. Berlin: Springer, 2002.Zwillinger, D. (Ed.). "Greatest Common Divisor." §2.3.5 in CRC Standard Mathematical Tables and Formulae, 30th ed. Boca Raton, FL: CRC Press, p. 91, 1996.

在 Wolfram|Alpha 中被引用

最大公约数

引用为

Weisstein, Eric W. "最大公约数。" 来自 MathWorld--Wolfram Web 资源。 https://mathworld.net.cn/GreatestCommonDivisor.html

主题分类