GCD

 In mathematics, the greatest common divisor (GCD) of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers. For two integers x, y, the greatest common divisor of x and y is denoted . For example, the GCD of 8 and 12 is 4, that is, .[1][2]

In the name "greatest common divisor", the adjective "greatest" may be replaced by "highest", and the word "divisor" may be replaced by "factor", so that other names include highest common factor (hcf), etc.[3][4][5][6] Historically, other names for the same concept have included greatest common measure.[7]


Properties

  • Every common divisor of a and b is a divisor of gcd(ab).
  • gcd(ab), where a and b are not both zero, may be defined alternatively and equivalently as the smallest positive integer d which can be written in the form d = ap + bq, where p and q are integers. This expression is called Bézout's identity. Numbers p and q like this can be computed with the extended Euclidean algorithm.
  • gcd(a, 0) = |a|, for a ≠ 0, since any number is a divisor of 0, and the greatest divisor of a is |a|.[2][5] This is usually used as the base case in the Euclidean algorithm.
  • If a divides the product bc, and gcd(ab) = d, then a/d divides c.
  • If m is a positive integer, then gcd(mamb) = m⋅gcd(ab).
  • If m is any integer, then gcd(a + mbb) = gcd(ab). Equivalently, gcd(a mod b,b) = gcd(a,b).
  • If m is a positive common divisor of a and b, then gcd(a/mb/m) = gcd(ab)/m.
  • The GCD is a commutative function: gcd(ab) = gcd(ba).
  • The GCD is an associative function: gcd(a, gcd(bc)) = gcd(gcd(ab), c). Thus gcd(abc, ...) can be used to denote the GCD of multiple arguments.
  • The GCD is a multiplicative function in the following sense: if a1 and a2 are relatively prime, then gcd(a1a2b) = gcd(a1b)⋅gcd(a2b).
  • gcd(ab) is closely related to the least common multiple lcm(ab): we have
    gcd(ab)⋅lcm(ab) = |ab|.
This formula is often used to compute least common multiples: one first computes the GCD with Euclid's algorithm and then divides the product of the given numbers by their GCD.
  • The following versions of distributivity hold true:
    gcd(a, lcm(bc)) = lcm(gcd(ab), gcd(ac))
    lcm(a, gcd(bc)) = gcd(lcm(ab), lcm(ac)).
  • If we have the unique prime factorizations of a = p1e1 p2e2 ⋅⋅⋅ pmem and b = p1f1 p2f2 ⋅⋅⋅ pmfm where ei ≥ 0 and fi ≥ 0, then the GCD of a and b is
    gcd(a,b) = p1min(e1,f1) p2min(e2,f2) ⋅⋅⋅ pmmin(em,fm).
  • It is sometimes useful to define gcd(0, 0) = 0 and lcm(0, 0) = 0 because then the natural numbers become a complete distributive lattice with GCD as meet and LCM as join operation.[23] This extension of the definition is also compatible with the generalization for commutative rings given below.
  • In a Cartesian coordinate systemgcd(ab) can be interpreted as the number of segments between points with integral coordinates on the straight line segment joining the points (0, 0) and (ab).
  • For non-negative integers a and b, where a and b are not both zero, provable by considering the Euclidean algorithm in base n:[24]
    gcd(na − 1, nb − 1) = ngcd(a,b) − 1.
  • An identity involving Euler's totient function:
    {\displaystyle \gcd(a,b)=\sum _{k|a{\text{ and }}k|b}\varphi (k).}
  • {\displaystyle \sum _{k=1}^{n}\gcd(k,n)=n\prod _{p|n}\left(1+\nu _{p}(n)\left(1-{\frac {1}{p}}\right)\right)} where \nu _{p}(n) is the p-adic valuation.

Comments