Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Are 12 and 35 relatively prime?
Yes
gcd(12, 35) = 1
Greatest common divisor 1
Relatively prime Yes (gcd = 1)

What is the Relatively Prime Calculator?

Two integers are relatively prime (also called coprime) when the only positive integer that divides both of them is 1. In other words, their greatest common divisor (gcd) is exactly 1. This calculator takes two whole numbers and instantly tells you whether they are coprime, along with their gcd.

How to use it

Enter your two integers in the fields for a and b and submit. The tool computes \(\gcd(a, b)\) using the Euclidean algorithm. If the gcd is 1, the numbers are relatively prime; otherwise they share a common factor and are not coprime. Negative signs are ignored because coprimality depends only on absolute values.

The formula explained

The Euclidean algorithm repeatedly replaces the pair \((a, b)\) with \((b, a \bmod b)\) until the second value becomes 0. The last non-zero value is the gcd. The numbers are coprime precisely when this gcd equals 1:

$$\text{Coprime} \iff \gcd\left(\text{a},\ \text{b}\right) = 1$$

For example, 8 and 15 share no prime factors, so \(\gcd = 1\) and they are coprime, even though neither is itself prime.

Advertisement
Two numbers sharing only the common factor 1, shown as overlapping factor sets
Two numbers are coprime when their only shared factor is 1, so \(\gcd(a, b) = 1\).

Worked example

Take \(a = 12\) and \(b = 35\). The factors of 12 are 2 and 3; the factors of 35 are 5 and 7. They share no common prime factor, so \(\gcd(12, 35) = 1\). Therefore 12 and 35 are relatively prime. By contrast, 12 and 18 share the factor 6, so \(\gcd = 6\) and they are not coprime.

Euclidean algorithm steps reducing two numbers down to gcd of 1
The Euclidean algorithm reduces the pair step by step until the remainder reveals \(\gcd = 1\).

FAQ

Do coprime numbers have to be prime? No. Coprime means they share no common factor greater than 1; the numbers themselves need not be prime (e.g., 8 and 9).

Is 1 coprime with every number? Yes. \(\gcd(1, n) = 1\) for any integer \(n\), so 1 is relatively prime to every integer.

Are two even numbers ever coprime? No. Any two even numbers share the factor 2, so their gcd is at least 2.

Last updated: