Relatively Prime Calculator
Solve relatively prime problems step-by-step with our free calculator. See formulas, worked examples, and clear explanations.
Calculator
Adjust values & calculateEuclidean Algorithm Steps
Numbers Coprime to 15 (first 20)
Formula
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).
Last reviewed: December 2025
Worked Examples
Example 1: Checking if 15 and 28 are Relatively Prime
Example 2: Checking if 24 and 36 are Relatively Prime
Background & Theory
The Relatively Prime Calculator applies the following established principles and formulas. Mathematics rests on a hierarchy of number systems, each extending the previous. The natural numbers (1, 2, 3, ...) support counting and ordering. The integers add negative values and zero, enabling subtraction without restriction. The rational numbers, expressible as p/q where p and q are integers and q is nonzero, close the system under division. The real numbers fill the gaps left by irrationals such as the square root of 2 or pi, forming a complete ordered field. The complex numbers, written as a + bi where i is the square root of negative one, complete the algebraic closure of the reals and allow every polynomial to have a root. Prime factorization states that every integer greater than one is uniquely expressible as a product of primes, a result known as the Fundamental Theorem of Arithmetic. Computing the greatest common divisor (GCD) of two integers relies most efficiently on the Euclidean algorithm: repeatedly replace the larger number with the remainder when it is divided by the smaller, until the remainder is zero. The last nonzero remainder is the GCD. The least common multiple (LCM) follows from the identity LCM(a, b) = |a * b| / GCD(a, b). Modular arithmetic defines equivalence classes of integers that share the same remainder under division by a modulus n. Fermat's Little Theorem and Euler's Theorem arise from this structure and underpin modern cryptography. Logarithms are the inverses of exponential functions. If b raised to the power x equals y, then the logarithm base b of y equals x. The natural logarithm uses base e, approximately 2.71828. Combinatorics counts arrangements and selections. The number of ordered arrangements (permutations) of r objects from n distinct objects is nPr = n! / (n - r)!. The number of unordered selections (combinations) is nCr = n! / (r! * (n - r)!). Pascal's triangle arranges these binomial coefficients so that each entry equals the sum of the two entries directly above it. The Fibonacci sequence, defined by F(1) = 1, F(2) = 1, and F(n) = F(n-1) + F(n-2), appears throughout nature and connects deeply to the golden ratio via Binet's formula.
History
The history behind the Relatively Prime Calculator traces back through the following developments. Mathematics as a systematic discipline traces to ancient Mesopotamia. Babylonian clay tablets dating to around 1800 BCE demonstrate knowledge of quadratic equations, Pythagorean triples, and base-60 arithmetic, suggesting a practical mathematical tradition far preceding Greek formalism. Euclid of Alexandria compiled the Elements around 300 BCE, establishing the axiomatic method that would define rigorous mathematics for over two thousand years. His work organized plane geometry, number theory, and proportion into logically chained propositions derived from a small set of postulates. The algorithm bearing his name for computing GCDs appears in Book VII and remains in use today. In the 9th century, the Persian scholar Muhammad ibn Musa Al-Khwarizmi wrote Al-Kitab al-mukhtasar fi hisab al-jabr wal-muqabala, the treatise whose title gave algebra its name. He systematized the solution of linear and quadratic equations and described procedures that operated on unknowns as objects, a conceptual leap away from purely numerical calculation. Rene Descartes introduced coordinate geometry in 1637 by uniting algebra and Euclidean geometry, allowing curves to be studied through equations. This synthesis set the stage for calculus. Isaac Newton and Gottfried Wilhelm Leibniz independently developed calculus during the 1660s and 1670s, triggering a priority dispute that lasted decades and divided British and Continental mathematicians. Carl Friedrich Gauss proved the Fundamental Theorem of Algebra in 1799, showing that every nonconstant polynomial has at least one complex root. His Disquisitiones Arithmeticae of 1801 established modern number theory. David Hilbert's formalist program at the turn of the 20th century sought to place all of mathematics on an explicit axiomatic foundation, a project that Kurt Godel's incompleteness theorems of 1931 showed to be fundamentally limited. Alan Turing's work in the 1930s on computability introduced the theoretical model of the stored-program computer and linked mathematical logic directly to the limits of algorithmic calculation. His proof that no algorithm can decide in general whether an arbitrary program will halt or run forever placed fundamental boundaries on what mathematics can mechanically determine, and it opened the discipline now known as theoretical computer science.
Frequently Asked Questions
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.
Can more than two numbers be relatively prime?
Yes, the concept of coprimality extends to sets of more than two numbers in two different ways. A set of numbers is mutually coprime (or pairwise coprime) if every pair within the set is coprime. A weaker condition is that the set is setwise coprime, meaning the GCD of all numbers together is 1. For example, 6, 10, and 15 are setwise coprime since GCD(6, 10, 15) = 1, but they are NOT pairwise coprime because GCD(6, 10) = 2. In contrast, 5, 7, and 11 are pairwise coprime since every pair has GCD = 1. The Chinese Remainder Theorem requires pairwise coprimality of moduli for its standard formulation.
How do you make two numbers relatively prime?
If two numbers are not relatively prime, you can reduce them to a coprime pair by dividing both by their GCD. For example, 12 and 18 have GCD = 6, so dividing both by 6 gives 2 and 3, which are coprime. This process is exactly what happens when you simplify a fraction: 12/18 becomes 2/3 in lowest terms because you divided by the GCD. In modular arithmetic, you sometimes need to find a number coprime to a given modulus. One approach is to select prime numbers, since a prime p is coprime to any number that is not a multiple of p. In RSA key generation, the encryption exponent is chosen to be coprime to the totient by selecting a prime like 65537.
References
Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy