ArticleslgStudy

mathematics

Greatest common divisor

Greatest common divisor is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Greatest common divisor rather than just read about it. In short: In mathematics, the greatest common divisor (GCD), also known as greatest common factor (GCF), 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 gcd⁡(x,y).

Greatest common divisor — main illustration
Greatest common divisor — illustration

Key takeaways

  • Greatest common divisor belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Greatest common divisor to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Greatest common divisor from memory before moving on to harder problems.

Reference excerpt

In mathematics, the greatest common divisor (GCD), also known as greatest common factor (GCF), 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 gcd⁡(x,y). For example, the GCD of 8 and 12 is 4, that is, gcd(8, 12) = 4. 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. Historically, other names for the same concept have included greatest common measure. This notion can be extended to polynomials (see Polynomial greatest common divisor) and other commutative rings (see § In commutative rings below).

Overview

Definition The greatest common divisor (GCD) of integers a and b, at least one of which is nonzero, is the greatest positive integer d such that d is a divisor of both a and b; that is, there are integers e and f such that a = de and b = df, and d is the largest such integer. The GCD of a and b is generally denoted gcd(a, b). When one of a and b is zero, the GCD is the absolute value of the nonzero integer: gcd(a, 0) = gcd(0, a) = |a|. This case is important as the terminating step of the Euclidean algorithm. The above definition is unsuitable for defining gcd(0, 0), since there is no greatest integer n such that 0 × n = 0. However, zero is its own greatest divisor if greatest is understood in the context of the divisibility relation, so gcd(0, 0) is commonly defined as 0. This preserves the usual identities for GCD, and in particular Bézout's identity, namely that gcd(a, b) generates the same ideal as {a, b}. This convention is followed by many computer algebra systems. Nonetheless, some authors leave gcd(0, 0) undefined. The GCD of a and b is their greatest positive common divisor in the preorder relation of divisibility. This means that the common divisors of a and b are exactly the divisors of their GCD. This is commonly proved by using either Euclid's lemma, the fundamental theorem of arithmetic, or the Euclidean algorithm. This is the meaning of "greatest" that is used for the generalizations of the concept of GCD.

Example The number 54 can be expressed as a product of two integers in several different ways:

54×1=27×2=18×3=9×6. Thus the complete list of divisors of 54 is 1, 2, 3, 6, 9, 18, 27, 54. Similarly, the divisors of 24 are 1, 2, 3, 4, 6, 8, 12, 24. The numbers that these two lists have in common are the common divisors of 54 and 24, that is,

1,2,3,6. Of these, the greatest is 6, so it is the greatest common divisor:

gcd⁡(54,24)=6. Computing all divisors of the two numbers in this way is usually not efficient, especially for large numbers that have many divisors. Much more efficient methods are described in § Calculation.

Coprime numbers

Two numbers are called relatively prime, or coprime, if their greatest common divisor equals 1. For example, 9 and 28 are coprime.

A geometric view

For example, a 24-by-60 rectangular area can be divided into a grid of: 1-by-1 squares, 2-by-2 squares, 3-by-3 squares, 4-by-4 squares, 6-by-6 squares or 12-by-12 squares. Therefore, 12 is the greatest common divisor of 24 and 60. A 24-by-60 rectangular area can thus be divided into a grid of 12-by-12 squares, with two squares along one edge (24/12 = 2) and five squares along the other (60/12 = 5). 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.

Applications

Reducing fractions

The greatest common divisor is useful for reducing fractions to the lowest terms. For example, gcd(42, 56) = 14, therefore,

4256=3⋅144⋅14=34.

Least common multiple

The least common multiple of two integers that are not both zero can be computed from their greatest common divisor, by using the relation

lcm⁡(a,b)=|a⋅b|gcd⁡(a,b).

Calculation

Using prime factorizations Greatest common divisors can be computed by determining the prime factorizations of the two numbers and comparing factors. For example, to compute gcd(48, 180), we find the prime factorizations 48 = 24 · 31 and 180 = 22 · 32 · 51; the GCD is then 2min(4,2) · 3min(1,2) · 5min(0,1) = 22 · 31 · 50 = 12 The corresponding LCM is then 2max(4,2) · 3max(1,2) · 5max(0,1) = 24 · 32 · 51 = 720. In practice, this method is only feasible for small numbers, as computing prime factorizations takes too long.

Euclid's algorithm

The method introduced by Euclid for computing greatest common divisors is based on the fact that, given two positive integers a and b such that a > b, the common divisors of a and b are the same as the common divisors of a – b and b. So, Euclid's method for computing the greatest common divisor of two positive integers consists of replacing the larger number with the difference of the numbers, and repeating this until the two numbers are equal: that is their greatest common divisor. For example, to compute gcd(48,18), one proceeds as follows:

gcd⁡(48,18)→gcd⁡(48−18,18)=gcd⁡(30,18)→gcd⁡(30−18,18)=gcd⁡(12,18)→gcd⁡(12,18−12)=gcd⁡(12,6)→gcd⁡(12−6,6)=gcd⁡(6,6). So gcd(48, 18) = 6. This method can be very slow if one number is much larger than the other. So, the variant that follows is generally preferred.

Euclidean algorithm

A more efficient method is the Euclidean algorithm, a variant in which the difference of the two numbers a and b is replaced by the remainder of the Euclidean division (also called division with remainder) of a by b. Denoting this remainder as a mod b, the algorithm replaces (a, b) with (b, a mod b) repeatedly until the pair is (d, 0), where d is the greatest common divisor. For example, to compute gcd(48,18), the computation is as follows:

gcd⁡(48,18)→gcd⁡(18,48mod18)=gcd⁡(18,12)→gcd⁡(12,18mod12)=gcd⁡(12,6)→gcd⁡(6,12mod6)=gcd⁡(6,0). This again gives gcd(48, 18) = 6.

Binary GCD algorithm

… excerpt ends here. Continue reading the full article.

Illustrations

Greatest common divisor: Venn diagram of the factors of two positive integers a and b showing that a × b is the product of their least common multiple and their greatest common divisor
Venn diagram of the factors of two positive integers a and b showing that a × b is the product of their least common multiple and their greatest common divisor
Greatest common divisor: Thomae's function
Thomae's function

Worked examples

Example 1 — a first encounter with Greatest common divisor

Start with the simplest possible case. Write down what Greatest common divisor claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Greatest common divisor before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Greatest common divisor ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Greatest common divisor

In research
Greatest common divisor appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Greatest common divisor in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Greatest common divisor is common in secondary-school and first-year university syllabi. It links to neighbouring topics Multiplicative functions, so understanding it makes those chapters shorter.
In everyday life
Look for Greatest common divisor outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Greatest common divisor” →

How to study Greatest common divisor in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Greatest common divisor means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Greatest common divisor out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Greatest common divisor in simple terms?

In mathematics, the greatest common divisor (GCD), also known as greatest common factor (GCF), 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 gcd⁡(x,y).

Why does Greatest common divisor matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Greatest common divisor?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Greatest common divisor.

Tags

  • Multiplicative functions

Keep exploring