Advertisement

Relatively prime calculator

Enter two to ten whole numbers. The calculator reports the greatest common factor and says whether the set is coprime, pairwise coprime or neither.

Calculator

Separate whole numbers with commas, spaces or new lines.

Relatively prime
Yes: the greatest common factor of all the numbers is 1.
Pairwise coprime
Yes: every pair is coprime.
Greatest common factor of the set
1

Advertisement

How this calculator works

Two integers are relatively prime, or coprime, when their only common positive factor is 1. For a whole set the test is weaker: the set is relatively prime when the greatest common factor of all its members is 1. Pairwise coprime is stricter, requiring every individual pair to be coprime. The set 6, 10 and 15 shows the difference: no single factor divides all three, yet 6 and 10 share 2, so the set is relatively prime but not pairwise coprime.

Formula

A set is relatively prime when gcd(a₁, a₂, ..., aₙ) = 1. It is pairwise coprime when gcd(aᵢ, aⱼ) = 1 for every i ≠ j. The gcd is computed with Euclid's algorithm.

Worked example

12 and 25 are relatively prime because their factors are {1, 2, 3, 4, 6, 12} and {1, 5, 25}, which meet only at 1. The numbers 12 and 18 are not: they share the factor 6.

Advertisement

Frequently asked questions

Does 1 count as relatively prime to anything?

Yes. The only positive factor of 1 is 1, so gcd(1, n) = 1 for every integer n. A set containing 1 is therefore always relatively prime.

Are relatively prime numbers always prime?

No. The name describes the relationship, not the numbers. 8 and 9 are both composite, but they share no factor other than 1, so they are relatively prime.

How is pairwise coprime different?

A set can have gcd 1 without every pair being coprime, as with 6, 10 and 15. Pairwise coprime rules out even that: every two members must be coprime. For two numbers the two tests agree.

What happens with negative numbers?

Signs are ignored. The greatest common factor is defined on absolute values, so -12 and 25 are relatively prime in exactly the same way as 12 and 25.

Sources

Advertisement