Coprime integers
{{Short description|Two numbers without shared prime factors}}
In number theory, two integers {{mvar|a}} and {{mvar|b}} are coprime, relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1.{{cite book |last1=Eaton |first1=James S. |title=A Treatise on Arithmetic |date=1872 |publisher=Thompson, Bigelow & Brown |location=Boston |page=49 |url=https://archive.org/details/atreatiseonarit05eatogoog |access-date=10 January 2022 |quote=Two numbers are mutually prime when no whole number but one will divide each of them}} Consequently, any prime number that divides {{mvar|a}} does not divide {{mvar|b}}, and vice versa. This is equivalent to their greatest common divisor (GCD) being 1.{{harvnb|Hardy|Wright|2008|loc=p. 6}} One says also {{mvar|a}} is prime to {{mvar|b}} or {{mvar|a}} is coprime with {{mvar|b}}.
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 a reduced fraction are coprime, by definition.
Notation and testing
When the integers {{mvar|a}} and {{mvar|b}} are coprime, the standard way of expressing this fact in mathematical notation is to indicate that their greatest common divisor is one, by the formula {{math|1=gcd(a, b) = 1}} or {{math|1=(a, b) = 1}}. In their 1989 textbook Concrete Mathematics, Ronald Graham, Donald Knuth, and Oren Patashnik proposed an alternative notation to indicate that {{mvar|a}} and {{mvar|b}} are relatively prime and that the term "prime" be used instead of coprime (as in {{mvar|a}} is prime to {{mvar|b}}).{{citation|first1=R. L.|last1=Graham|first2=D. E.|last2=Knuth|first3=O.|last3=Patashnik|title=Concrete Mathematics / A Foundation for Computer Science|publisher=Addison-Wesley|year=1989|page=115|isbn=0-201-14236-8}}
A fast way to determine whether two numbers are coprime is given by the Euclidean algorithm and its faster variants such as binary GCD algorithm or Lehmer's GCD algorithm.
The number of integers coprime with a positive integer {{mvar|n}}, between 1 and {{mvar|n}}, is given by Euler's totient function, also known as Euler's phi function, {{math|φ(n)}}.
A set 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 that {{mvar|a}} and {{mvar|b}} are coprime for every pair {{math|(a, b)}} of different integers in the set. The set {{math|{2, 3, 4} }} is coprime, but it is not pairwise coprime since 2 and 4 are not relatively prime.
Properties
The numbers 1 and −1 are the only integers coprime with every integer, and they are the only integers that are coprime with 0.
A number of conditions are equivalent to {{mvar|a}} and {{mvar|b}} being coprime:
- No prime number divides both {{mvar|a}} and {{mvar|b}}.
- There exist integers {{mvar|x, y}} such that {{math|1=ax + by = 1}} (see Bézout's identity).
- The integer {{mvar|b}} has a multiplicative inverse modulo {{mvar|a}}, meaning that there exists an integer {{mvar|y}} such that {{math|by ≡ 1 (mod a)}}. In ring-theoretic language, {{mvar|b}} is a unit in the ring {{tmath|\Z/a\Z}} of integers modulo {{mvar|a}}.
- Every pair of congruence relations for an unknown integer {{mvar|x}}, of the form {{math|x ≡ k (mod a)}} and {{math|x ≡ m (mod b)}}, has a solution (Chinese remainder theorem); in fact the solutions are described by a single congruence relation modulo {{mvar|ab}}.
- The least common multiple of {{mvar|a}} and {{mvar|b}} is equal to their product {{mvar|ab}}, i.e. {{math|1=lcm(a, b) = ab}}.{{harvnb|Ore|1988|loc=p. 47}}
As a consequence of the third point, if {{mvar|a}} and {{mvar|b}} are coprime and {{math|br ≡ bs (mod a)}}, then {{math|r ≡ s (mod a)}}.{{harvnb|Niven|Zuckerman|1966|loc=p. 22, Theorem 2.3(b)}} That is, we may "divide by {{mvar|b}}" when working modulo {{mvar|a}}. Furthermore, if {{math|b1, b2}} are both coprime with {{mvar|a}}, then so is their product {{math|b1b2}} (i.e., modulo {{mvar|a}} it is a product of invertible elements, and therefore invertible);{{harvnb|Niven|Zuckerman|1966|loc=p. 6, Theorem 1.8}} this also follows from the first point by Euclid's lemma, which states that if a prime number {{mvar|p}} divides a product {{mvar|bc}}, then {{mvar|p}} divides at least one of the factors {{mvar|b, c}}.
As a consequence of the first point, if {{mvar|a}} and {{mvar|b}} are coprime, then so are any powers {{mvar|ak}} and {{mvar|bm}}.
If {{mvar|a}} and {{mvar|b}} are coprime and {{mvar|a}} divides the product {{mvar|bc}}, then {{mvar|a}} divides {{mvar|c}}.{{harvnb|Niven|Zuckerman|1966|loc=p.7, Theorem 1.10}} This can be viewed as a generalization of Euclid's lemma.
The two integers {{mvar|a}} and {{mvar|b}} are coprime if and only if the point with coordinates {{math|(a, b)}} in a Cartesian coordinate system would be "visible" via an unobstructed line of sight from the origin {{math|(0, 0)}}, in the sense that there is no point with integer coordinates anywhere on the line segment between the origin and {{math|(a, b)}}. (See figure 1.)
In a sense that can be made precise, the probability that two randomly chosen integers are coprime is {{math|6/π2}}, which is about 61% (see {{slink||Probability of coprimality}}, below).
Two natural numbers {{mvar|a}} and {{mvar|b}} are coprime if and only if the numbers {{math|2a − 1}} and {{math|2b − 1}} are coprime.{{harvnb|Rosen|1992|loc=p. 140}} As a generalization of this, following easily from the Euclidean algorithm in base {{math|n > 1}}:
:
Coprimality in sets
A set of integers can also be called coprime or setwise coprime if the greatest 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 be pairwise coprime (or pairwise relatively prime, mutually coprime or mutually 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 dividing all of them is 1), but they are not pairwise coprime (because {{math|1=gcd(4, 6) = 2}}).
The concept of pairwise coprimality is important as a hypothesis in many results in number theory, such as the Chinese remainder theorem.
It is possible for an infinite set of integers to be pairwise coprime. Notable examples include the set of all prime numbers, the set of elements in Sylvester's sequence, and the set of all Fermat numbers.
Coprimality in ring ideals
Two ideals {{mvar|A}} and {{mvar|B}} in a commutative ring {{mvar|R}} are called coprime (or comaximal) if This generalizes Bézout's identity: with this definition, two principal ideals ({{mvar|a}}) and ({{mvar|b}}) in the ring of integers {{tmath|\Z}} are coprime if and only if {{mvar|a}} and {{mvar|b}} are coprime. If the ideals {{mvar|A}} and {{mvar|B}} of {{mvar|R}} are coprime, then furthermore, if {{mvar|C}} is a third ideal such that {{mvar|A}} contains {{mvar|BC}}, then {{mvar|A}} contains {{mvar|C}}. The Chinese remainder theorem can be generalized to any commutative ring, using coprime ideals.
Probability of coprimality
Given two randomly chosen integers {{mvar|a}} and {{mvar|b}}, it is reasonable to ask how likely it is that {{mvar|a}} and {{mvar|b}} are coprime. In this determination, it is convenient to use the characterization that {{mvar|a}} and {{mvar|b}} are coprime if and only if no prime number divides both of them (see Fundamental theorem of arithmetic).
Informally, the probability that any number is divisible by a prime (or in fact any integer) {{mvar|p}} is {{tmath|\tfrac{1}{p};}} for example, every 7th integer is divisible by 7. Hence the probability that two numbers are both divisible by {{mvar|p}} is {{tmath|\tfrac{1}{p^2},}} and the probability that at least one of them is not is {{tmath|1-\tfrac{1}{p^2}.}} 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 primes {{mvar|p}} and {{mvar|q}} if and only if it is divisible by {{mvar|pq}}; the latter event has probability {{tmath|\tfrac{1}{pq}.}} 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,
:
Here {{mvar|ζ}} refers to the Riemann zeta function, the identity relating the product over primes to {{math|ζ(2)}} is an example of an Euler product, and the evaluation of {{math|ζ(2)}} as {{math|π2/6}} is the Basel problem, solved by Leonhard Euler in 1735.
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 of natural density. For each positive integer {{mvar|N}}, let {{mvar|P{{sub|N}}}} be the probability that two randomly chosen numbers in are coprime. Although {{mvar|P{{sub|N}}}} will never equal {{math|6/π2}} exactly, with workThis theorem was proved by Ernesto Cesàro in 1881. For a proof, see {{harvnb|Hardy|Wright|2008|loc=Theorem 332}} one can show that in the limit as the probability {{mvar|P{{sub|N}}}} approaches {{math|6/π2}}.
More generally, the probability of {{mvar|k}} randomly chosen integers being setwise coprime is {{tmath|\tfrac{1}{\zeta(k)}.}}
Generating all coprime pairs
File:Coprime8.svg 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 {{math|(m, n)}} (with {{math|m > n}}) can be arranged in two disjoint complete ternary trees, one tree starting from {{math|(2, 1)}} (for even–odd and odd–even pairs),{{Citation |last=Saunders |first=Robert |name-list-style=amp |last2=Randall |first2=Trevor |title=The family tree of the Pythagorean triplets revisited |journal=Mathematical Gazette |volume=78 |date=July 1994 |pages=190–193|doi=10.2307/3618576 }}. and the other tree starting from {{math|(3, 1)}} (for odd–odd pairs).{{Citation |last=Mitchell |first=Douglas W. |title=An alternative characterisation of all primitive Pythagorean triples |journal=Mathematical Gazette |volume=85 |date=July 2001 |pages= 273–275 |doi=10.2307/3622017}}. The children of each vertex {{math|(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
- if
b then (a,b) is a child of(m,n)=(b, 2b-a) along branch 1.
In all cases
Another (much simpler) way to generate a tree of positive coprime pairs {{math|(m, n)}} (with {{math|m > n}}) is by means of two generators
Applications
In machine design, an even, uniform gear wear is achieved by choosing the tooth counts of the two gears meshing together to be relatively prime. When a 1:1 gear ratio is desired, a gear relatively prime to the two equal-size gears may be inserted between them.
In pre-computer cryptography, some Vernam cipher machines combined several loops of key tape of different lengths. Many rotor machines combine rotors of different numbers of teeth. Such combinations work best when the entire set of lengths are pairwise coprime.
Klaus Pommerening.
[https://www.staff.uni-mainz.de/pommeren/Cryptology/Classic/4_Cylinder/LongPeriods.html "Cryptology: Key Generators with Long Periods"].
David Mowry.
[https://www.nsa.gov/Portals/70/documents/about/cryptologic-heritage/historical-figures-publications/publications/wwii/german_cipher.pdf "German Cipher Machines of World War II"].
2014.
p. 16; p. 22.
Dirk Rijmenants.
[https://www.ciphermachinesandcryptology.com/en/onetimepad.htm "Origins of One-time pad"].
Gustavus J. Simmons.
[https://www.britannica.com/topic/Vernam-Vigenere-cipher "Vernam-Vigenère cipher"].
Generalizations
This concept can be extended to other algebraic structures than {{tmath|\Z;}} for example, polynomials whose greatest common divisor is 1 are called coprime polynomials.
See also
{{wiktionary|coprime}}
Notes
{{Reflist}}
References
- {{citation | first1=G.H.|last1=Hardy | author1-link=G. H. Hardy |first2=E.M.|last2=Wright|author2-link=E. M. Wright | title=An Introduction to the Theory of Numbers | edition=6th | publisher=Oxford University Press | year=2008 | isbn=978-0-19-921986-5}}
- {{citation|first1=Ivan|last1=Niven|first2=Herbert S.|last2=Zuckerman|title=An Introduction to the Theory of Numbers|year=1966|edition=2nd|publisher=John Wiley & Sons}}
- {{citation|first=Oystein|last=Ore|title=Number Theory and Its History|year=1988|orig-year=1948|publisher=Dover|isbn=978-0-486-65620-5}}
- {{citation|first=Kenneth H.|last=Rosen|title=Elementary Number Theory and its Applications|edition=3rd|year=1992|publisher=Addison-Wesley|isbn=978-0-201-57889-8}}
Further reading
- {{Citation |last=Lord |first=Nick |title=A uniform construction of some infinite coprime sequences |journal=Mathematical Gazette |volume=92 |date=March 2008 |pages=66–70 }}.