Coprime Checker – Test Whether Numbers Are Relatively Prime
Two integers are coprime — also called relatively prime or mutually prime — when their greatest common divisor is exactly 1. In symbols, gcd(a, b) = 1, meaning the numbers share no positive factor other than 1. This checker tests two or more integers, reports the GCD it used to decide, shows the prime factorization of each value, and can even list every number coprime to a given N or find the nearest coprime to a target. It is a fast way to answer a question that appears everywhere from fraction arithmetic to cryptography.
How the Check Works
The engine behind every mode is the Euclidean algorithm, one of the oldest algorithms still in daily use. It repeatedly replaces the larger number with the remainder of dividing it by the smaller one — gcd(a, b) = gcd(b, a mod b) — until the remainder reaches zero. The last non-zero value is the GCD. Because the numbers shrink quickly, even twelve-digit inputs settle in a handful of steps. If that GCD comes out as 1, the numbers are coprime; anything larger is a factor they share, and the checker highlights it.
Pairwise Versus Setwise Coprime
With three or more numbers there are two different questions to ask. A set is pairwise coprime when every possible pair has a GCD of 1, and setwise coprime when only the GCD of the whole collection is 1. Pairwise is the stronger condition and always implies setwise, but not the reverse. The set {6, 10, 15} is the textbook example: no pair inside it is coprime — 6 and 10 share 2, 6 and 15 share 3, 10 and 15 share 5 — yet the overall GCD is 1, so the set is setwise coprime without being pairwise coprime. The multi-number mode draws a colour-coded matrix so you can spot exactly which pairs clash.
Prime Factorization and Shared Factors
Coprimality is really a statement about prime factors: two numbers are coprime precisely when their factorizations have no prime in common. The checker factorizes each input by trial division and displays the result in tidy exponent form, such as 48 = 2⁴ × 3 and 35 = 5 × 7. Because those two share no prime, they are coprime. When they are not, the tool names the offending primes directly, which makes the verdict easy to verify by hand.
Range Lists and Nearest Coprime
The range mode lists every integer in an interval that is coprime with a chosen N. Counting those values is closely tied to Euler's totient function φ(N), which gives the number of integers from 1 to N that are coprime with it; the tool reports the coprime density as an estimate of φ(N)/N. The nearest-coprime mode starts at a target value and steps outward until it lands on a number coprime with the reference — handy when you need a value close to a preferred figure but free of shared factors, as when picking an RSA public exponent.
Where Coprimality Matters
A fraction is in lowest terms exactly when its numerator and denominator are coprime, so this test underlies every fraction simplifier. In RSA cryptographythe public exponent must be coprime with Euler's totient of the modulus for a valid modular inverse to exist. Engineers deliberately choose coprime gear-tooth counts so that the same pair of teeth rarely meets twice, spreading wear evenly. Calendar and scheduling cycles with coprime periods realign only after the product of their lengths, which is why coprime numbers keep repeating patterns from lining up too soon.
Reading the Output and Limits
Every mode gives a clear coprime-or-not banner, the GCD, and an explanation you can copy, download as text or CSV, or share through a link that restores your inputs. Values may be as large as 10¹², the multi-number list is capped at twenty entries to keep the pairwise matrix legible, and the range sweep is limited to ten thousand values. Zero is rejected because gcd(0, n) = n makes a coprime verdict meaningless, and negative inputs are allowed only when you enable them, in which case the check uses absolute values.