Description
Euclidean algorithm is used to find the gcd of two integers.
For two sorted integers a,b (a > b)
gcd(a,b)=gcd(a,a mod b)
Proof
Step one: Left to Right
Let a=k1b+r and d is a common divisor of a and b
then
ad=k1bd+rd=m
Because of
d|a∧d|b
m is an integer, which implies
i.e. d is a divisor of r
d is a common divisor of a and
Step two: Right to Left
Let a=k1b+r and d is a common divisor of
From a=k1b+r we get
r=a−k1b
then
rd=ad−k1bd
Because of
d|r∧d|a
then
d|b
So the divisors of a and
本文介绍了一种利用欧几里得算法求两个整数的最大公约数的方法。对于两个已排序的整数 a 和 b (a > b),通过递归公式 gcd(a, b) = gcd(a, a mod b) 来简化问题,直至其中一个数为 0。文中详细证明了该算法的正确性。
768

被折叠的 条评论
为什么被折叠?



