Relatively Prime Calculator
Solve relatively prime problems step-by-step with our free calculator. See formulas, worked examples, and clear explanations.
Reviewed by Manoj Kumar, Mathematics Educator
Formula
Two numbers a and b are relatively prime if GCD(a, b) = 1
The greatest common divisor (GCD) is computed using the Euclidean algorithm. If the GCD equals 1, the numbers share no common prime factors and are called relatively prime, coprime, or mutually prime. The LCM is calculated as (a x b) / GCD(a, b).
Worked Examples
Example 1: Checking if 15 and 28 are Relatively Prime
Problem:Determine whether 15 and 28 are relatively prime and find their GCD.
Solution:Prime factors of 15: 3, 5\nPrime factors of 28: 2, 2, 7\nNo common prime factors exist.\nEuclidean algorithm: GCD(28, 15) -> 28 = 1 x 15 + 13 -> 15 = 1 x 13 + 2 -> 13 = 6 x 2 + 1 -> 2 = 2 x 1 + 0\nGCD = 1
Result:15 and 28 ARE relatively prime (GCD = 1), LCM = 420
Example 2: Checking if 24 and 36 are Relatively Prime
Problem:Determine whether 24 and 36 are relatively prime.
Solution:Prime factors of 24: 2, 2, 2, 3\nPrime factors of 36: 2, 2, 3, 3\nCommon prime factors: 2, 2, 3 -> GCD = 12\nEuclidean algorithm: GCD(36, 24) -> 36 = 1 x 24 + 12 -> 24 = 2 x 12 + 0\nGCD = 12, not 1.
Result:24 and 36 are NOT relatively prime (GCD = 12). Reduced coprime form: 2 and 3.
Frequently Asked Questions
What does it mean for two numbers to be relatively prime?
Two numbers are relatively prime (also called coprime or mutually prime) when their greatest common divisor (GCD) is exactly 1, meaning they share no common factors other than 1. For example, 8 and 15 are relatively prime because the factors of 8 are 1, 2, 4, 8 and the factors of 15 are 1, 3, 5, 15, and the only shared factor is 1. Importantly, the numbers themselves do not need to be prime. The numbers 14 and 25 are both composite but are still relatively prime since they share no common prime factors. This concept is fundamental in number theory and has practical applications in cryptography and modular arithmetic.
How is the GCD used to determine if numbers are relatively prime?
The greatest common divisor is the largest positive integer that divides both numbers without leaving a remainder. If the GCD of two numbers equals 1, those numbers are relatively prime by definition. The most efficient method for computing the GCD is the Euclidean algorithm, which works by repeatedly replacing the larger number with the remainder of dividing the larger by the smaller. For instance, GCD(48, 35): 48 = 1 times 35 + 13, then 35 = 2 times 13 + 9, then 13 = 1 times 9 + 4, then 9 = 2 times 4 + 1, then 4 = 4 times 1 + 0. The last nonzero remainder is 1, confirming they are coprime.
Are consecutive integers always relatively prime?
Yes, any two consecutive integers are always relatively prime, and this can be proven mathematically. Suppose n and n+1 share a common factor d greater than 1. Then d would divide both n and n+1, which means d would also divide their difference: (n+1) - n = 1. But no integer greater than 1 can divide 1, creating a contradiction. Therefore consecutive integers are always coprime. This property extends to other patterns as well. For example, n and 2n+1 are always coprime, as are consecutive Fibonacci numbers. These relationships are foundational results in elementary number theory.
How are relatively prime numbers used in cryptography?
Relatively prime numbers are the cornerstone of RSA encryption, one of the most widely used public-key cryptosystems. In RSA, two large prime numbers p and q are multiplied to create n = p times q. The encryption exponent e must be coprime to phi(n) = (p-1)(q-1). The decryption key d is then the modular multiplicative inverse of e modulo phi(n), which exists precisely because e and phi(n) are coprime. Without the coprimality requirement, the inverse would not exist and decryption would be impossible. This application of number theory secures internet banking, email encryption, digital signatures, and virtually all secure online communications.
References
Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy