Relatively Prime Calculator
Check whether two integers or a set of integers are coprime, inspect their greatest common divisor, and review every pair.
Inputs
Pair mode uses exactly two values. Set mode accepts three to ten values.
Enter whole numbers from 1 to 1,000,000,000. Commas are accepted only as standard thousands separators.
Live result
The overall GCD is 1, but 4 and 6 share a factor greater than 1.
Number details
Prime factorizations make shared prime factors easy to spot.
| Position | Integer | Prime factorization | Distinct prime factors |
|---|---|---|---|
| #1 | 4 | 2² | 2 |
| #2 | 6 | 2 × 3 | 2, 3 |
| #3 | 21 | 3 × 7 | 3, 7 |
Pair checks
A set is pairwise coprime only when every row below has GCD 1.
| Pair | First integer | Second integer | Pair GCD | Coprime? |
|---|---|---|---|---|
| #1 and #2 | 4 | 6 | 2 | No |
| #1 and #3 | 4 | 21 | 1 | Yes |
| #2 and #3 | 6 | 21 | 3 | No |
How to use the relatively prime calculator
What this calculator does. It determines whether two positive integers are relatively prime, or whether a collection of three to ten positive integers is setwise and pairwise coprime. The central test is the greatest common divisor, abbreviated GCD: integers are coprime when the relevant GCD equals 1. The calculator also explains the result with prime factorizations and a row-by-row pair table. It does not test whether each input is itself a prime number; composite values such as 4, 9, or 25 can still be coprime to another value.
When to use it. Use the tool to check number-theory exercises, simplify fractions by confirming that numerator and denominator share no factor, verify modular-arithmetic conditions, or distinguish setwise coprimality from the stricter pairwise condition. The underlying definition is summarized in Wolfram MathWorld's relatively prime numbers reference.
How to calculate. The calculator opens with the demonstration set 4, 6, and 21, so the first result and the example Excel workbook are ready immediately.
- Choose Check for: select “A pair of numbers” for exactly two values or “A set of numbers” for three to ten values.
- Replace the demonstration entries under Positive integers. In set mode, use Add another number or the remove buttons to adjust the list.
- Read the live Classification, then confirm the Overall GCD, Setwise status, Pairwise status, and Coprime pairs.
- Use Number details to inspect each prime factorization and Pair checks to locate a pair that shares a factor.
- Select Download Excel to export the current validated inputs and results. Reset clears the demonstration and all calculated content; Excel export remains unavailable until a complete valid pair or set is entered again.
Input guide. Check for is a required mode selector. Pair mode expects two values, while set mode requires at least three and permits no more than ten. Changing the mode changes the classification rules and the number of input rows. Positive integers are required whole numbers from 1 through 1,000,000,000. Plain digits such as 462 and correctly grouped values such as 1,000,000 are accepted. Decimals, signs, scientific notation, decimal commas, malformed grouping, and zero are rejected rather than silently reinterpreted. A realistic entry is 35. Increasing or decreasing an integer can introduce or remove common prime factors, so the result is not generally monotonic. A common mistake is assuming that two composite numbers cannot be coprime; 14 and 15 are both composite but have GCD 1.
Output guide. Classification is the primary conclusion. In pair mode it is either “Relatively prime” or “Not relatively prime.” In set mode, “Pairwise coprime” means every pair has GCD 1; “Setwise coprime, but not pairwise” means only the GCD of the entire set is 1; and “Not coprime as a set” means the overall GCD exceeds 1. Overall GCD is an exact integer identity driven by every input. Setwise status reports whether that overall GCD is 1. Pairwise status reports whether every possible pair passes. Coprime pairs counts passing pairs out of all n(n – 1)/2 possible pairs. In Number details, Position identifies the input row, Integer repeats the validated value, Prime factorization shows its prime-power decomposition, and Distinct prime factors removes repeated powers. In Pair checks, Pair identifies two positions, First integer and Second integer repeat their values, Pair GCD gives the exact shared divisor, and Coprime? is Yes only when that pair's GCD is 1.
Worked example. The startup values are 4, 6, and 21. The calculator first computes GCD(4, 6, 21) = 1, so the set is setwise coprime. It then checks all three pairs: GCD(4, 6) = 2, GCD(4, 21) = 1, and GCD(6, 21) = 3. Only one pair is coprime, so the exact first-open classification is Setwise coprime, but not pairwise, with 1 of 3 coprime pairs. The prime factorizations 4 = 2², 6 = 2 × 3, and 21 = 3 × 7 show why the first and third pair checks fail.
Learn more. The GCD is efficiently found with the Euclidean algorithm. A deeper connection is Bézout's identity, which states that the GCD of two integers can be written as an integer linear combination of them.
How the calculation works
Two integers a and b are coprime exactly when GCD(a, b) = 1.
For a set, the calculator reduces the list through the same GCD operation. If that final GCD is 1, the set is setwise coprime. It separately evaluates every pair to test pairwise coprimality. The distinction matters: 4, 6, and 21 have no factor shared by all three numbers, but 4 and 6 share 2 while 6 and 21 share 3.
Common interpretation mistakes
- Coprime does not mean prime. It describes a relationship between numbers, not the primality of each number.
- Setwise does not imply pairwise. An overall GCD of 1 can coexist with individual pairs whose GCD is greater than 1.
- One is coprime to every positive integer. Its only positive divisor is 1.
- Two even integers cannot be coprime. They always share the factor 2.