Coprime Checker

Test whether two whole numbers share any factor besides one.

Math and PercentUpdated 2026-11-192 min read
Coprime Checker
A whole number with magnitude of at least 1.
Result
...
Greatest common divisor...
Pair tested...

What it does

Two integers are coprime, or relatively prime, when no positive integer greater than one divides both of them. Equivalently, their greatest common divisor is one. The numbers do not have to be prime themselves.

This tool runs the Euclidean algorithm on the absolute values of the pair. It reports the greatest common divisor and states plainly whether the numbers are coprime. Zero and fractional inputs are rejected with a clear message.

The idea is central to arithmetic. A fraction is in lowest terms exactly when its numerator and denominator are coprime, and many results about modular inverses depend on the same condition.

The Euclidean algorithm is fast even for very large integers because each step replaces the pair with a smaller one. The tool caps inputs at a trillion to keep the display and arithmetic predictable.

How to use

  1. Enter the first whole number.
  2. Enter the second whole number.
  3. Read the coprime result in the main area.
  4. Check the greatest common divisor shown below.
  5. Try a pair such as 12 and 21 to see a non-coprime case.
  6. Use the result to confirm a fraction is in lowest terms.

Formula

gcd(a,b) found by repeating (a,b) becomes (b, a mod b) until b is zero.
a, b
Whole numbers whose magnitude is at least 1.
gcd
The largest positive integer dividing both numbers.
mod
The remainder after division.

The tool takes absolute values first, so a pair with negatives is judged exactly like its positive version. The algorithm stops when the remainder reaches zero, and the last non-zero remainder is the gcd. A gcd of one means the pair is coprime. Zero is not allowed because every integer divides zero, which would make the question meaningless.

Worked example

Example: 8 and 9

Inputs a = 8 and b = 9.

  1. Start with 9 and 8.
  2. 9 mod 8 = 1, so the pair becomes 8 and 1.
  3. 8 mod 1 = 0, so the algorithm stops.
  4. The last non-zero remainder is 1.
  5. A gcd of 1 means the pair is coprime.
  6. Tool shows Coprime with gcd 1 for 8 and 9.

Reference table

Greatest common divisors for familiar pairs
First numberSecond numberGCDResult
891Coprime
7201Coprime
11001Coprime
12213Not coprime
14217Not coprime

Limits

  • Only whole numbers are accepted.
  • Zero is rejected because coprimality with zero is not useful here.
  • Inputs are capped at one trillion in magnitude.
  • The tool tests a pair, not a whole set of numbers.

Common mistakes

  • Assuming both numbers must be prime to be coprime.
  • Entering decimals and expecting a rounding to happen.
  • Forgetting that a negative sign does not change the result.
  • Confusing the gcd with the least common multiple.
  • Reading a gcd above one as a sign the numbers are prime.

Try it yourself

Quick checks. Answers sit tucked under each question.

Are 8 and 9 coprime?

Yes. Their gcd is 1.

What is gcd(12, 21)?

3, so the pair is not coprime.

Does 1 form a coprime pair with 100?

Yes. The gcd is 1.

Questions

What does coprime mean?

The only positive integer dividing both numbers is 1.

Do both numbers need to be prime?

No. For example 8 and 9 are both composite yet coprime.

How is the gcd found?

With the Euclidean algorithm of repeated remainders.

What about negative numbers?

They are treated by absolute value, so the sign is ignored.

Why is zero not allowed?

Every integer divides zero, so the test would be trivial.

How does this help with fractions?

A fraction is in lowest terms when numerator and denominator are coprime.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.