Innumber theory, twointegersa andb arecoprime,relatively prime ormutually prime if the only positive integer that is adivisor of both of them is 1.[1] Consequently, anyprime number that dividesa does not divideb, and vice versa. This is equivalent to theirgreatest common divisor (GCD) being 1.[2] One says alsoais prime tob orais coprime withb.
The numbers 8 and 9 are coprime, despite the fact that neither—considered individually—is a prime number, since 1 is their only common divisor. On the other hand, 6 and 9 are not coprime, because they are both divisible by 3. The numerator and denominator of areduced fraction are coprime, by definition.
When the integersa andb are coprime, the standard way of expressing this fact inmathematical notation is to indicate that their greatest common divisor is one, by the formulagcd(a,b) = 1 or(a,b) = 1. In their 1989 textbookConcrete Mathematics,Ronald Graham,Donald Knuth, andOren Patashnik proposed an alternative notation to indicate thata andb are relatively prime and that the term "prime" be used instead of coprime (as ina isprime tob).[3]
The number of integers coprime with a positive integern, between 1 andn, is given byEuler's totient function, also known as Euler's phi function,φ(n).
Aset of integers can also be called coprime if its elements share no common positive factor except 1. A stronger condition on a set of integers is pairwise coprime, which means thata andb are coprime for every pair(a,b) of different integers in the set. The set{2, 3, 4} is coprime, but it is not pairwise coprime since 2 and 4 are not relatively prime.
There exist integersx, y such thatax +by = 1 (seeBézout's identity).
The integerb has amultiplicative inverse moduloa, meaning that there exists an integery such thatby ≡ 1 (moda). In ring-theoretic language,b is aunit in thering ofintegers moduloa.
Every pair ofcongruence relations for an unknown integerx, of the formx ≡k (moda) andx ≡m (modb), has a solution (Chinese remainder theorem); in fact the solutions are described by a single congruence relation moduloab.
As a consequence of the third point, ifa andb are coprime andbr ≡bs (moda), thenr ≡s (moda).[5] That is, we may "divide byb" when working moduloa. Furthermore, ifb1,b2 are both coprime witha, then so is their productb1b2 (i.e., moduloa it is a product of invertible elements, and therefore invertible);[6] this also follows from the first point byEuclid's lemma, which states that if a prime numberp divides a productbc, thenp divides at least one of the factorsb, c.
As a consequence of the first point, ifa andb are coprime, then so are any powersak andbm.
Ifa andb are coprime anda divides the productbc, thena dividesc.[7] This can be viewed as a generalization of Euclid's lemma.
Figure 1. The numbers 4 and 9 are coprime. Therefore, the diagonal of a 4 × 9 lattice does not intersect any otherlattice points
The two integersa andb are coprimeif and only if the point with coordinates(a,b) in aCartesian coordinate system would be "visible" via an unobstructed line of sight from the origin(0, 0), in the sense that there is no point with integer coordinates anywhere on the line segment between the origin and(a,b). (See figure 1.)
In a sense that can be made precise, theprobability that two randomly chosen integers are coprime is6/π2, which is about 61% (see§ Probability of coprimality, below).
Twonatural numbersa andb are coprime if and only if the numbers2a − 1 and2b − 1 are coprime.[8] As a generalization of this, following easily from theEuclidean algorithm inbasen > 1:
Aset of integers can also be calledcoprime orsetwise coprime if thegreatest common divisor of all the elements of the set is 1. For example, the integers 6, 10, 15 are coprime because 1 is the only positive integer that divides all of them.
If every pair in a set of integers is coprime, then the set is said to bepairwise coprime (orpairwise relatively prime,mutually coprime ormutually relatively prime). Pairwise coprimality is a stronger condition than setwise coprimality; every pairwise coprime finite set is also setwise coprime, but the reverse is not true. For example, the integers 4, 5, 6 are (setwise) coprime (because the only positive integer dividingall of them is 1), but they are notpairwise coprime (becausegcd(4, 6) = 2).
The concept of pairwise coprimality is important as a hypothesis in many results in number theory, such as theChinese remainder theorem.
It is possible for aninfinite set of integers to be pairwise coprime. Notable examples include the set of all prime numbers, the set of elements inSylvester's sequence, and the set of allFermat numbers.
Given two randomly chosen integersa andb, it is reasonable to ask how likely it is thata andb are coprime. In this determination, it is convenient to use the characterization thata andb are coprime if and only if no prime number divides both of them (seeFundamental theorem of arithmetic).
Informally, the probability that any number is divisible by a prime (or in fact any integer)p is for example, every 7th integer is divisible by 7. Hence the probability that two numbers are both divisible byp is and the probability that at least one of them is not is Any finite collection of divisibility events associated to distinct primes is mutually independent. For example, in the case of two events, a number is divisible by primesp andq if and only if it is divisible bypq; the latter event has probability If one makes the heuristic assumption that such reasoning can be extended to infinitely many divisibility events, one is led to guess that the probability that two numbers are coprime is given by a product over all primes,
There is no way to choose a positive integer at random so that each positive integer occurs with equal probability, but statements about "randomly chosen integers" such as the ones above can be formalized by using the notion ofnatural density. For each positive integerN, letPN be the probability that two randomly chosen numbers in are coprime. AlthoughPN will never equal6/π2 exactly, with work[9] one can show that in the limit as the probabilityPN approaches6/π2.
More generally, the probability ofk randomly chosen integers being setwise coprime is[10]
Thetree rooted at (2, 1). The root (2, 1) is marked red, its three children are shown in orange, third generation is yellow, and so on in the rainbow order.
All pairs of positive coprime numbers(m,n) (withm >n) can be arranged in two disjoint completeternary trees, one tree starting from(2, 1) (for even–odd and odd–even pairs),[11] and the other tree starting from(3, 1) (for odd–odd pairs).[12] The children of each vertex(m,n) are generated as follows:
Branch 1:
Branch 2:
Branch 3:
This scheme is exhaustive and non-redundant with no invalid members. This can be proved by remarking that, if is a coprime pair with then
if then is a child of along branch 3;
if then is a child of along branch 2;
if then is a child of along branch 1.
In all cases is a "smaller" coprime pair with This process of "computing the father" can stop only if either or In these cases, coprimality, implies that the pair is either or
Another (much simpler) way to generate a tree of positive coprime pairs(m,n) (withm >n) is by means of two generators and, starting with the root. The resultingbinary tree, theCalkin–Wilf tree, is exhaustive and non-redundant, which can be seen as follows. Given a coprime pair one recursively applies or depending on which of them yields a positive coprime pair withm >n. Since only one does, the tree is non-redundant. Since by this procedure one is bound to arrive at the root, the tree is exhaustive.
In machine design, an even, uniformgear wear is achieved by choosing the tooth counts of the two gears meshing together to be relatively prime. When a 1:1gear ratio is desired, a gear relatively prime to the two equal-size gears may be inserted between them.
In pre-computercryptography, someVernam cipher machines combined several loops of key tape of different lengths. Manyrotor machines combine rotors of different numbers of teeth. Such combinations work best when the entire set of lengths are pairwise coprime.[13][14][15][16]
TwoidealsA andB in acommutative ringR are called coprime (orcomaximal) if This generalizesBézout's identity: with this definition, twoprincipal ideals (a) and (b) in the ring of integers are coprime if and only ifa andb are coprime. If the idealsA andB ofR are coprime, then furthermore, ifC is a third ideal such thatA containsBC, thenA containsC. TheChinese remainder theorem can be generalized to any commutative ring, using coprime ideals.
^Eaton, James S. (1872).A Treatise on Arithmetic. Boston: Thompson, Bigelow & Brown. p. 49. Retrieved10 January 2022.Two numbers aremutually prime when no whole number butone will divide each of them
^Nymann, J.E. (1972), "On the probability that k positive integers are relatively prime",Journal of Number Theory,4 (5):469–473,doi:10.1016/0022-314X(72)90038-8.
^Saunders, Robert & Randall, Trevor (July 1994), "The family tree of the Pythagorean triplets revisited",Mathematical Gazette,78:190–193,doi:10.2307/3618576.
^Mitchell, Douglas W. (July 2001), "An alternative characterisation of all primitive Pythagorean triples",Mathematical Gazette,85:273–275,doi:10.2307/3622017.