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.
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.
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.