Coprime Checker
Test whether two whole numbers share any factor besides one.
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
- Enter the first whole number.
- Enter the second whole number.
- Read the coprime result in the main area.
- Check the greatest common divisor shown below.
- Try a pair such as 12 and 21 to see a non-coprime case.
- Use the result to confirm a fraction is in lowest terms.
Formula
- 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.
- Start with 9 and 8.
- 9 mod 8 = 1, so the pair becomes 8 and 1.
- 8 mod 1 = 0, so the algorithm stops.
- The last non-zero remainder is 1.
- A gcd of 1 means the pair is coprime.
- Tool shows Coprime with gcd 1 for 8 and 9.
Reference table
| First number | Second number | GCD | Result |
|---|---|---|---|
| 8 | 9 | 1 | Coprime |
| 7 | 20 | 1 | Coprime |
| 1 | 100 | 1 | Coprime |
| 12 | 21 | 3 | Not coprime |
| 14 | 21 | 7 | Not 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
- LibreTexts, Mount Royal University: Relatively Prime numbers
- University of California Berkeley: Notes on coprimality