Coprime Number Checker & Pairwise Coprime Calculator

Check one pair or a list of integers. See whether every pair has GCD 1, identify conflicts, and compare pairwise with collective coprimality. Inputs stay in your browser.

Enter two or more integers

Negative signs are allowed and do not change coprimality. Use underscores—not commas or spaces—inside a grouped integer, for example 1_000_003.

Coprimality result

Your result will appear here.

The starting example 8, 9, 25 is pairwise coprime because all three pair GCDs equal 1.

Advertisement

Coprime and pairwise coprime numbers

Two integers a and b are coprime, also called relatively prime, exactly when their greatest common divisor is 1:

gcd(|a|, |b|) = 1

A list a1, …, an is pairwise coprime when gcd(|ai|, |aj|) = 1 for every pair of different positions i and j.

The integers do not need to be prime. For instance, 8 and 9 are both composite and are coprime because they share no positive divisor other than 1.

Pairwise versus collectively coprime

Pairwise coprime: 8, 9, 25

gcd(8, 9) = 1
gcd(8, 25) = 1
gcd(9, 25) = 1

Every pair passes, so the list is pairwise coprime. Its collective GCD is also 1.

Collectively, but not pairwise: 6, 10, 15

gcd(6, 10) = 2
gcd(6, 15) = 3
gcd(10, 15) = 5

The GCD of all three numbers is 1, but no pair has GCD 1. Collective coprimality does not imply pairwise coprimality.

How the calculator checks every pair

  1. Parse the entries as exact signed integers and use their absolute values for GCD calculations.
  2. For each of the n(n − 1) / 2 distinct pairs, apply the Euclidean algorithm until the remainder is zero.
  3. Mark a pair as coprime when its final nonzero remainder—the GCD—is 1.
  4. Report the whole list as pairwise coprime only if every pair passes.
  5. Separately reduce the entire list by GCD to show whether it is collectively coprime.

Exactness and limits: JavaScript BigInt arithmetic avoids floating-point rounding. The 50-integer and 500-digit limits cap the maximum work at 1,225 pair checks and keep unusually large inputs responsive.

Coprime number FAQ

When are two numbers coprime?

They are coprime when their greatest common divisor is 1. Equivalently, they share no positive factor other than 1.

What does pairwise coprime mean?

Every pair formed from different positions in the list must be coprime. Testing only the GCD of the whole list is not enough.

What is the difference between pairwise and collectively coprime?

Collectively coprime means the whole-list GCD is 1. Pairwise coprime requires every two-number GCD to be 1, so it is the stronger condition. The list 6, 10, 15 demonstrates the difference.

Do coprime numbers have to be prime?

No. Numbers may be composite and still be coprime. For example, gcd(8, 9) = 1 even though 8 and 9 are composite.

How are negative numbers and zero handled?

The GCD uses absolute values, so signs do not matter. Since gcd(0, n) = |n|, zero is coprime only with 1 or −1. Two zeros have GCD 0 and are not coprime.

Are duplicate entries allowed?

Yes, because positions are tested exactly as entered. Repeated 1 or −1 values remain pairwise coprime, while two repeated values with absolute value greater than 1 have that value as their GCD and fail.

Is my input private?

Yes. Validation and exact GCD calculations happen entirely in your browser. The tool does not upload, store, or add the list to the page URL.

Explore more tools