Relatively Prime Calculator

Check whether two integers are coprime by calculating their greatest common divisor with the Euclidean algorithm.

Check relative primality
Enter two whole numbers to find their greatest common divisor.

About relatively prime numbers

Two integers are relatively prime, or coprime, when their greatest common divisor is exactly one. The numbers do not each need to be prime. For example, 14 and 25 are both composite in the broader sense that 14 has factors 2 and 7 while 25 has factor 5, yet they share no positive factor except 1. By contrast, 18 and 24 share factors 2, 3, and 6, so their greatest common divisor is 6 and they are not relatively prime. This calculator finds the greatest common divisor using the Euclidean algorithm. Starting with the absolute values of the two integers, it repeatedly replaces the larger calculation pair with the divisor and the remainder. For 18 and 24, the divisions produce remainders that eventually lead to 6 and then 0. The last nonzero remainder is the greatest common divisor. The algorithm is efficient even for large integers because each remainder rapidly reduces the size of the next calculation. Relative primality is a relationship between numbers rather than a property of one number alone. The integer 8 is relatively prime to 15 because their greatest common divisor is 1, but it is not relatively prime to 12 because they share the factor 4. Consecutive integers are always relatively prime: any common divisor of n and n plus 1 would also have to divide their difference, which is 1. Similarly, any integer is relatively prime to 1. Coprime numbers are central to fraction simplification. A fraction is in lowest terms precisely when its numerator and denominator are relatively prime. They also appear in modular arithmetic, Euler's totient function, cyclic patterns, gear ratios, and public-key cryptography. In RSA-style mathematics, choosing values with a greatest common divisor of one ensures that a modular inverse exists. Negative inputs are allowed because signs do not change positive common factors; the calculator uses absolute values for the greatest common divisor. Zero requires care. The greatest common divisor of zero and a nonzero integer is the absolute value of that integer, so zero is relatively prime only to 1 or negative 1. The pair zero and zero has no conventionally defined greatest common divisor and is rejected. Use integer inputs because relative primality and divisibility are discrete number-theory concepts.

Relatively prime examples

The greatest common divisor determines every answer.

Integer pairResultReason
14 and 25Relatively primeTheir greatest common divisor is 1.
18 and 24Not relatively primeBoth numbers are divisible by 6.
35 and 64Relatively primeThey have no common prime factor.
0 and 1Relatively primeThe greatest common divisor of 0 and 1 is 1.

How to check if numbers are relatively prime

  1. Enter the first integer, including a negative sign if applicable.
  2. Enter the second integer.
  3. Select Check relative primality.
  4. Confirm whether the displayed greatest common divisor equals one.

Relatively prime calculator FAQ

Do both numbers have to be prime?

No, relative primality only means the two numbers share no factor greater than one. Two composite numbers such as 8 and 15 can therefore be relatively prime.

Are consecutive integers always relatively prime?

Yes, any common divisor would have to divide their difference of one. Therefore every pair of consecutive integers has a greatest common divisor of one.

Is 1 relatively prime to every integer?

Yes, the only positive factor of 1 is 1 itself. Consequently its greatest common divisor with every integer is 1.

Can zero be relatively prime to another number?

Zero is relatively prime to 1 and negative 1 because those pairs have greatest common divisor 1. With any other integer, the greatest common divisor has a magnitude greater than one.

Why are coprime numbers useful?

They identify fully reduced fractions and guarantee modular inverses in many settings. This relationship is also fundamental to number theory and cryptographic algorithms.