Relatively Prime Calculator
Enter two integers to check if they are coprime, with full Euclidean algorithm steps.
🔗 What is a Relatively Prime Calculator?
Relatively prime numbers (also called coprime or mutually prime numbers) are two integers that share no common factor other than 1. In formal terms, two integers a and b are relatively prime when their greatest common factor (GCF, also written GCD) equals exactly 1. The numbers themselves do not need to be prime. Composite numbers can still be coprime with each other if their prime factorizations do not overlap at all.
This calculator accepts any two positive integers, computes their GCF using the Euclidean algorithm, and immediately states whether the pair is coprime. It also shows the full step-by-step Euclidean algorithm working, the prime factorization of each number in exponent notation, and a complete list of every divisor the two numbers share. For coprime inputs the list of common divisors is simply {1}.
Coprimality appears across a wide range of contexts. In elementary arithmetic it determines whether a fraction is already in lowest terms: a/b is fully reduced when GCF(a, b) = 1. In scheduling problems, two periodic events that repeat every a and b units will next coincide after exactly a times b time units (rather than fewer) when a and b are coprime. In number theory and abstract algebra, coprimality underlies the Chinese Remainder Theorem, Euler's totient function, and modular inverses. In cryptography, RSA requires the public exponent to be coprime with the totient of the modulus so that a unique decryption exponent exists.
A common source of confusion is the difference between a number being prime and two numbers being coprime. Primality is a property of one number (it has no divisors other than 1 and itself). Coprimality is a relationship between two numbers (their GCF is 1). Composite numbers can be coprime: 8 and 9 are both composite but coprime because they share no prime factor. Conversely, two prime numbers are always coprime with each other, but a prime is not coprime with its own multiples.
📐 Formula
📖 How to Use This Calculator
Steps
💡 Example Calculations
Example 1 - Two consecutive integers (14 and 15)
Are 14 and 15 relatively prime?
Example 2 - Numbers that share a common factor (12 and 18)
Are 12 and 18 relatively prime?
Example 3 - Two large composite numbers (35 and 64)
Are 35 and 64 relatively prime?
Example 4 - A prime and a composite (7 and 49)
Are 7 and 49 relatively prime?
❓ Frequently Asked Questions
🔗 Related Calculators
What does relatively prime mean in mathematics?
Two integers are relatively prime (also called coprime or mutually prime) when their greatest common factor (GCF) equals 1. This means they share no common prime factors. For example, 8 and 9 are relatively prime because 8 = 2 cubed and 9 = 3 squared, so they share no primes. The number 1 is relatively prime to every positive integer. Being relatively prime is about the relationship between two numbers, not a property of either number alone.
How do you check if two numbers are relatively prime?
Use the Euclidean algorithm to find the GCF of the two numbers. If the result is 1, the numbers are relatively prime. Steps: (1) Divide the larger by the smaller and take the remainder. (2) Replace the larger with the smaller and the smaller with the remainder. (3) Repeat until the remainder is 0. The last non-zero remainder is the GCF. If it equals 1, the numbers are coprime. Example: GCF(14, 15) gives remainder 14 = 0 times 15 + 14, then 15 = 1 times 14 + 1, then 14 = 14 times 1 + 0. GCF = 1, so they are coprime.
Are all prime numbers relatively prime to each other?
Yes, any two distinct prime numbers are always relatively prime. Since a prime p has no factors other than 1 and itself, two distinct primes share only the factor 1, giving GCF = 1. For example, GCF(7, 11) = 1. However, note that a prime is NOT relatively prime to its own multiples: GCF(7, 14) = 7, not 1.
What is the relationship between coprime numbers and LCM?
When two numbers a and b are relatively prime, their LCM equals their product: LCM(a, b) = a times b. This follows from the general identity LCM(a, b) = a times b divided by GCF(a, b), and when GCF = 1 the division changes nothing. For example, GCF(8, 9) = 1, so LCM(8, 9) = 72 = 8 times 9.
Are 0 and any number relatively prime?
No. GCF(0, n) = n for any positive integer n (every integer divides 0), so GCF(0, n) equals n, which is greater than 1 for n greater than 1. Only GCF(0, 1) = 1, making 0 and 1 the single coprime pair involving 0 by this convention. Most calculators, including this one, require positive inputs to avoid this edge case.
What are some examples of relatively prime pairs?
Common coprime pairs include: (8, 9), (14, 15), (35, 36), (4, 9), (5, 7), (12, 25), (8, 15). All consecutive integers form coprime pairs. Two numbers whose prime factorizations share no prime in common are always coprime, regardless of how large they are.
Are 1 and any number always relatively prime?
Yes. GCF(1, n) = 1 for every positive integer n because the only positive divisor of 1 is 1 itself. So 1 is coprime with every positive integer. This makes 1 unique: it is the only positive integer coprime with itself (GCF(1, 1) = 1), while every other number has GCF(n, n) = n, which equals 1 only when n = 1.
What does relatively prime mean in number theory and cryptography?
In number theory, coprimality is central to modular arithmetic. Euler's theorem states that a raised to the power phi(n) is congruent to 1 mod n whenever GCF(a, n) = 1, where phi is Euler's totient function. RSA public-key cryptography exploits this: the key exponent e must satisfy GCF(e, phi(n)) = 1 to guarantee a unique decryption exponent d exists. Without coprimality, modular inverses fail to exist and the encryption scheme breaks down.
Can three or more numbers be mutually relatively prime?
Yes, a set of integers is mutually (or pairwise) relatively prime when every pair from the set has GCF = 1. Example: 6, 35, and 143 are pairwise coprime because GCF(6, 35) = 1, GCF(6, 143) = 1, and GCF(35, 143) = 1. Note that pairwise coprime is stronger than just requiring GCF of the whole set to be 1. For instance, GCF(6, 10, 15) = 1, but the numbers are not pairwise coprime because GCF(6, 10) = 2.
How does the Euclidean algorithm find the GCF?
The Euclidean algorithm uses the property that GCF(a, b) = GCF(b, a mod b). Starting with the two numbers, repeatedly replace the larger with the smaller and the smaller with the remainder, until the remainder is 0. The last non-zero value is the GCF. For GCF(48, 18): 48 = 2 times 18 + 12; 18 = 1 times 12 + 6; 12 = 2 times 6 + 0. GCF = 6. The algorithm is efficient even for numbers with hundreds of digits.
What is the difference between coprime and prime?
A prime number has exactly two positive divisors (1 and itself), and this is a property of a single number. Coprime (relatively prime) describes a relationship between two numbers: they are coprime if their GCF is 1. A composite number can be coprime with another number. For example, 8 (composite, 2 cubed) and 9 (composite, 3 squared) are coprime because they share no prime factors.
How do you simplify a fraction using GCF?
Divide both numerator and denominator by their GCF. For 18/24: GCF(18, 24) = 6, so 18/24 = 3/4. The fraction is now in lowest terms because 3 and 4 are relatively prime (GCF = 1). A fraction a/b is in lowest terms if and only if GCF(a, b) = 1. You can verify this with the Relatively Prime Calculator by entering the simplified numerator and denominator.