Lably
Skip to content

Coprime integers

Two numbers without shared prime factors

  • 8 min read
  • 7 chapters
  • 1 lab on Lably

Learn it on Lably

The numbers 8 and 9 are coprime, despite the fact that neither—considered individually—is a prime number, since 1 is their only common divisor. On the other hand, 6 and 9 are not coprime, because they are both divisible by 3. The numerator and denominator of a reduced fraction are coprime, by definition.

Notation and testing

When the integers a and b are coprime, the standard way of expressing this fact in mathematical notation is to indicate that their greatest common divisor is one, by the formula gcd(a, b) = 1 or (a, b) = 1. In their 1989 textbook Concrete Mathematics, Ronald Graham, Donald Knuth, and Oren Patashnik proposed an alternative notation a⊥b to indicate that a and b are relatively prime and that the term "prime" be used instead of coprime (as in a is prime to b).

A fast way to determine whether two numbers are coprime is given by the Euclidean algorithm and its faster variants such as binary GCD algorithm or Lehmer's GCD algorithm.

The number of integers coprime to a positive integer n, between 1 and n, is given by Euler's totient function, also known as Euler's phi function, φ(n).

A set of integers can also be called coprime if its elements share no common positive factor except 1. A stronger condition on a set of integers is pairwise coprime, which means that a and b are coprime for every pair (a, b) of different integers in the set. The set {2, 3, 4} is coprime, but it is not pairwise coprime since 2 and 4 are not relatively prime.

Sign in to keep reading

6 more chapters are free with a Lably account.

More in Number theory