Relatively Prime Calculator

Result

Enter at least two positive integers and click Calculate to check if they are relatively prime.

What Is a Relatively Prime Pair?

Two natural numbers are described as relatively prime (or coprime, mutually prime) when the only positive integer that divides both of them is 1. Equivalently, their greatest common divisor — often written as gcd⁡(a,b)\gcd(a,b) — equals 1. This condition is also captured by Bézout’s identity: there exist integers xx and yy such that ax+by=1a x + b y = 1. Because the numbers share no prime factor, any divisor of one cannot divide the other unless that divisor is 1.

A common misconception is that coprime numbers must themselves be primes. In fact, two composite numbers can be relatively prime as long as they have no overlapping prime factors. For instance, 14 and 15 are both composite ( 14=2×714 = 2 \times 7, 15=3×515 = 3 \times 5 ), yet they share only the factor 1, so they are coprime.

It follows directly that two even numbers can never be relatively prime, because every even number shares the factor 2. On the other hand, the number 1 is coprime with every integer, since its only divisor is 1 and therefore the GCD of 1 and any other number is always 1.

How to Check Whether Two Numbers Are Coprime

Identifying a relatively prime pair can be done through prime factorization:

  1. Write each number as a product of its prime factors (using exponent notation when possible).
  2. Compare the sets of primes that appear.
  3. If the only common prime factor is none (i.e., the sets are disjoint), then the numbers are coprime; otherwise they are not.

Example 1 — 14 and 27
14=2×714 = 2 \times 7
27=3327 = 3^{3}
No prime appears in both lists, so 14 and 27 are relatively prime.

Example 2 — 18 and 27
18=2×3218 = 2 \times 3^{2}
27=3327 = 3^{3}
The prime 3 appears in both factorizations, so 18 and 27 are not coprime. Their GCD is 9, not 1.

Generating a Number That Is Coprime to a Given Integer

To find a number that is relatively prime to a given integer aa:

  • First, compute the prime factorization of aa.
  • Any prime number that is not among those factors will be coprime to aa.
  • More generally, any natural number whose own prime factors avoid all the primes in aa’s factorization will also be coprime to aa.

Example: For a=45=32×5a = 45 = 3^{2} \times 5, the prime 2 does not appear in its factorization, so 2 is relatively prime to 45. Also, a composite like 14=2×714 = 2 \times 7 shares no prime factors with 45, confirming that 14 and 45 are coprime.

Coprimality in a Set of Numbers

When a set contains more than two integers, two levels of coprimality are distinguished:

  • Setwise coprime — the entire set has a GCD of 1.
    Example: {4,6,21}\{4, 6, 21\} has GCD(4,6,21) = 1, so the set is setwise coprime.
  • Pairwise coprime — every possible pair within the set is coprime.
    Example: {4,7,27}\{4, 7, 27\} is pairwise coprime, because (4,7), (4,27), and (7,27) are all coprime pairs.

Note that a set can be setwise coprime without being pairwise coprime (as {4,6,21}\{4, 6, 21\} shows: the pair (4,6) shares the factor 2).

Using the Online Free Relatively Prime Calculator

This free coprimes numbers checker online automates the factorization and comparison logic described above. Two modes are available:

  • Pair mode — select “a pair of numbers,” enter the two integers, and the tool instantly reports whether they are relatively prime.
  • Set mode — choose “a set of numbers” and enter up to ten integers. The calculator returns three possible outcomes: the set is setwise coprime, pairwise coprime, or not coprime at all.

With instant results and no manual steps, this relatively prime calculator provides a convenient way to check if numbers are relatively prime without performing factorisations yourself. Whether you are learning number theory or confirming properties of a set of integers, the coprime checker online offers a practical, time‑saving solution.

FAQ

1. What is the simplest method to verify whether two numbers are coprime?

The most straightforward way is to compute their greatest common divisor (GCD). If GCD = 1, the numbers are coprime. Alternatively, you can factor each number and check if they share any prime factor — if they don't, they are relatively prime.

2. Can two even numbers ever be relatively prime?

No, two even numbers can never be relatively prime because every even number is divisible by 2, so they always share the prime factor 2 (and thus their GCD is at least 2). At least one number must be odd for a pair to be coprime.

3. Is the number 1 relatively prime to every integer?

Yes. The only divisor of 1 is 1 itself, so the greatest common divisor between 1 and any other number is always 1. Therefore 1 is coprime with every natural number.

4. What is the difference between setwise coprime and pairwise coprime?

A set is setwise coprime if the GCD of all numbers together is 1. A set is pairwise coprime if every two-number combination within the set has a GCD of 1. A set can be setwise coprime without being pairwise coprime (e.g., {4,6,21} is setwise but not pairwise because 4 and 6 share factor 2).

How to Use

  1. Select whether you want to check a pair of numbers or a set of numbers.
  2. Enter at least two positive integers in the number fields.
  3. Click Calculate to determine if the numbers are relatively prime (coprime).