Coprime Checker

Enter two whole numbers to see their GCD and whether they are coprime.

How it is calculated

The tool finds the greatest common divisor with the Euclidean algorithm: set x = a, y = b, then repeat (x, y) → (y, x mod y) until y = 0; the last x is gcd(a, b). The two numbers are coprime exactly when that gcd is 1, and the tool reports the gcd together with a Yes/No answer (Yes = coprime). Both inputs must be whole numbers of at least 1; decimals such as 12.5, zero and negatives return no result. Digit strings are read exactly, so integers up to 9,223,372,036,854,775,807 (the 64-bit limit) give an exact gcd; anything larger gives no result. Remember that coprime does not mean prime: 8 and 15 are coprime although neither is prime, while 7 and 14 are not coprime although 7 is prime.

Worked example

Check 84 and 36. Step 1: 84 mod 36 = 12, so the pair becomes (36, 12). Step 2: 36 mod 12 = 0, so the algorithm stops and the last non-zero value is 12. The gcd is 12, which is not 1, so the answer is No: 84 and 36 are not coprime. They share the factors 2, 3, 4, 6 and 12.

Try this example →

Common mistakes

  • Assuming coprime means both numbers are prime. Only the gcd matters: 9 and 16 are coprime, 3 and 9 are not.
  • Thinking that consecutive numbers might share a factor. Any two consecutive whole numbers are always coprime, so a gcd of 1 is the expected result.
  • Reading the Yes/No answer as the gcd. The answer shows only Yes or No; the gcd is the separate first output.
  • Entering 0, a negative number or a decimal. Only positive whole numbers are accepted, so turn a fraction's numerator and denominator into integers first.
  • Pasting a number with more than 19 digits, such as a long key or factorial. Above the 64-bit limit the tool shows no result instead of an approximate gcd.

About this calculator

Two whole numbers are coprime, or relatively prime, if the only positive integer that divides both of them evenly is 1 — their greatest common divisor (GCD) equals 1, even though neither number individually needs to be prime. This calculator finds that GCD using the Euclidean algorithm, one of the oldest algorithms in mathematics, which repeatedly replaces the larger number with the remainder of dividing it by the smaller until the remainder reaches zero.

Coprimality is a load-bearing concept well beyond number theory homework: RSA public-key cryptography requires choosing an encryption exponent that is coprime with a totient value to guarantee the encryption is mathematically invertible, gear designers deliberately choose coprime tooth counts for meshing gears to spread wear evenly across all tooth combinations rather than repeating the same pairs, and coprime denominators are what let fractions be added by finding a true least common denominator.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators