Greatest Common Divisor (GCD) - Euclidean algorithm

The Euclidean algorithm calculates the greatest common divisor (GCD) of two natural numbers a and b. The greatest common divisor g is the largest natural number that divides both a and b without leaving a remainder. Synonyms for the GCD include the greatest common factor (GCF), the highest common factor (HCF), and the greatest common measure (GCM). The greatest common divisor is often written as gcd(ab) or, more simply, as (ab),[1] although the latter notation is also used for other mathematical concepts, such as two-dimensional vectors.

If gcd(ab) = 1, then a and b are said to be coprime (or relatively prime).[2] This property does not imply that a or b are themselves prime numbers.[3] For example, neither 6 nor 35 is a prime number, since they both have two prime factors: 6 = 2 × 3 and 35 = 5 × 7. Nevertheless, 6 and 35 are coprime. No natural number other than 1 divides both 6 and 35, since they have no prime factors in common.

Greatest Common Divisor (GCD) - Euclidean algorithm_第1张图片
A 24-by-60 rectangle is covered with ten 12-by-12 square tiles, where 12 is the GCD of 24 and 60. More generally, an  a-by- b rectangle can be covered with square tiles of side-length  c only if  c is a common divisor of  a and  b.

Let g = gcd(ab). Since a and b are both multiples of g, they can be written a = mg and b = ng, and there is no larger number G > g for which this is true. The natural numbers m and n must be coprime, since any common factor could be factored out of m and n to make g greater. Thus, any other number c that divides both a and bmust also divide g. The greatest common divisor g of a and b is the unique (positive) common divisor of a and bthat is divisible by any other common divisor c.[4]


你可能感兴趣的:(Math)