Ma · Mathematics

What Is the Greatest Common Divisor of Prime Numbers?

Published By the 9to5Science editorial team

At a glance

  1. 1. Compare the primes

    Check whether the prime numbers are equal or distinct.

  2. 2. Use prime divisors

    A prime has only two positive divisors: 1 and itself.

  3. 3. State the gcd

    Distinct primes have gcd 1; equal primes have gcd equal to that prime.

The greatest common divisor depends on whether the prime numbers are distinct. Two different primes have no common positive divisor other than 1, so their greatest common divisor is 1. If the two numbers are the same prime, that prime divides both and is their greatest common divisor.

The rule for two primes

Let pp and qq be prime numbers. Then

gcd⁡(p,q)={p,p=q,1,p≠q.\gcd(p,q)= \begin{cases} p, & p=q,\\ 1, & p\ne q. \end{cases}

A prime number has exactly two positive divisors: 1 and itself. If pp and qq are distinct, they cannot share a prime divisor: the only prime divisor of pp is pp, and the only prime divisor of qq is qq. Since those are different, their only common positive divisor is 1.

If p=qp=q, the two numbers are identical. Their common divisors include both 1 and pp, and no positive divisor of pp is larger than pp. Therefore the gcd is pp.

Worked examples

Different primes: Find gcd⁡(7,19)\gcd(7,19). The positive divisors of 7 are 1 and 7; those of 19 are 1 and 19. The only common divisor is 1, so

gcd⁡(7,19)=1.\gcd(7,19)=1.

The same prime: Find gcd⁡(13,13)\gcd(13,13). Both numbers are 13, so 13 is their largest common positive divisor:

gcd⁡(13,13)=13.\gcd(13,13)=13.

The phrase “the gcd of prime numbers” can refer either to distinct primes or to a list that might repeat a prime. Check whether the values are distinct before automatically answering 1.

More than two primes

For a finite list of prime numbers, the same idea applies. If every entry is the same prime pp, the gcd is pp. If the list contains at least two different primes, its gcd is 1: any common divisor greater than 1 would have a prime divisor, and that prime would have to divide every number in the list. But distinct primes have no prime divisor in common.

For example,

gcd⁡(2,2,2)=2,gcd⁡(2,2,3)=1.\gcd(2,2,2)=2, \qquad \gcd(2,2,3)=1.

Repeated values do not change the rule; what matters is whether all the primes in the list are identical.

Common mistakes

  • Assuming the gcd is always 1: This is true for two distinct primes, but not for a prime paired with itself. For example, gcd⁡(11,11)=11\gcd(11,11)=11.
  • Confusing gcd with the product: The product of distinct primes is not their gcd. For 5 and 11, the product is 55, but the gcd is 1.
  • Mixing up gcd and least common multiple: For distinct primes, the gcd is 1 and the least common multiple is their product. For example, gcd⁡(3,7)=1\gcd(3,7)=1 and lcm⁡(3,7)=21\operatorname{lcm}(3,7)=21.
  • Treating 1 as a prime: Under the standard definition, 1 is not prime. It is the gcd of any two distinct primes, not one of the primes in such a pair.

The key check is simply whether the prime numbers are equal: equal primes have gcd equal to that prime; distinct primes have gcd 1.

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.