Misplaced Pages

Coprime integers

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

In number theory , two integers a and b are coprime , relatively prime or mutually prime if the only positive integer that is a divisor of both of them is 1. Consequently, any prime number that divides a does not divide b , and vice versa. This is equivalent to their greatest common divisor (GCD) being 1. One says also a is prime to b or a is coprime with b .

#230769

64-419: 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. When the integers a and b are coprime, the standard way of expressing this fact in mathematical notation

128-513: A n } {\displaystyle S=\{a_{1},a_{2},\dots ,a_{n}\}} 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

192-412: A / b ⁠ = ⁠ c / d ⁠ implies ad  =  bc , and so both sides of the latter must share the same prime factorization, yet a and b share no prime factors so the set of prime factors of a (with multiplicity) is a subset of those of c and vice versa, meaning a  =  c and by the same argument b  =  d . The fact that any rational number has

256-403: A / b ⁠ equals √ 2 , so does ⁠ 2 b − a / a − b ⁠ (since cross-multiplying this with ⁠ a / b ⁠ shows that they are equal). Since a  >  b (because √ 2 is greater than 1), the latter is a ratio of two smaller integers. This is a contradiction , so the premise that the square root of two has a representation as

320-573: A and b are both nonzero, the greatest common divisor of a and b can be computed by using least common multiple (LCM) of a and  b : but more commonly the LCM is computed from the GCD. Using Thomae's function f , which generalizes to a and b rational numbers or commensurable real numbers. Keith Slavin has shown that for odd a ≥ 1 : which is a function that can be evaluated for complex b . Wolfgang Schramm has shown that

384-419: A | or | d | < | b | , where | a | means the absolute value of a . (Two fractions ⁠ a / b ⁠ and ⁠ c / d ⁠ are equal or equivalent if and only if ad  =  bc .) For example, ⁠ 1 / 4 ⁠ , ⁠ 5 / 6 ⁠ , and ⁠ −101 / 100 ⁠ are all irreducible fractions. On

448-426: A = b = 3 . The binary GCD algorithm is particularly easy to implement and particularly efficient on binary computers. Its computational complexity is The square in this complexity comes from the fact that division by 2 and subtraction take a time that is proportional to the number of bits of the input. The computational complexity is usually given in terms of the length n of the input. Here, this length

512-439: A and b are coprime if and only if the point with coordinates ( a , b ) in a Cartesian 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, the probability that two randomly chosen integers are coprime

576-457: A and b are exactly the divisors of their GCD. This is commonly proved by using either Euclid's lemma , the fundamental theorem of arithmetic , or the Euclidean algorithm . This is the meaning of "greatest" that is used for the generalizations of the concept of GCD. The number 54 can be expressed as a product of two integers in several different ways: Thus the complete list of divisors of 54

640-433: A and b being coprime: As a consequence of the third point, if a and b are coprime and br ≡ bs (mod a ) , then r ≡ s (mod a ) . That is, we may "divide by b " when working modulo a . Furthermore, if b 1 , b 2 are both coprime with a , then so is their product b 1 b 2 (i.e., modulo a it is a product of invertible elements, and therefore invertible); this also follows from

704-413: A and b , at least one of which is nonzero, is the greatest positive integer d such that d is a divisor of both a and b ; that is, there are integers e and f such that a = de and b = df , and d is the largest such integer. The GCD of a and b is generally denoted gcd( a , b ) . When one of a and b is zero, the GCD is the absolute value of the nonzero integer: gcd(

SECTION 10

#1732858277231

768-506: A and b , it is reasonable to ask how likely it is that a and b are coprime. In this determination, it is convenient to use the characterization that a and 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) p is ⁠ 1 p ; {\displaystyle {\tfrac {1}{p}};} ⁠ for example, every 7th integer

832-502: A is prime to b ). 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 n , between 1 and n , is given by Euler's totient function , also known as Euler's phi function, φ ( n ) . A set of integers can also be called coprime if its elements share no common positive factor except 1. A stronger condition on

896-467: A monic polynomial . Greatest common divisor In mathematics , the greatest common divisor ( GCD ), also known as greatest common factor (GCF) , of two or more integers , which are not all zero, is the largest positive integer that divides each of the integers. For two integers x , y , the greatest common divisor of x and y is denoted gcd ( x , y ) {\displaystyle \gcd(x,y)} . For example,

960-535: A ) and ( b ) in the ring of integers ⁠ Z {\displaystyle \mathbb {Z} } ⁠ are coprime if and only if a and b are coprime. If the ideals A and B of R are coprime, then A B = A ∩ B ; {\displaystyle AB=A\cap B;} furthermore, if C is a third ideal such that A contains BC , then A contains C . The Chinese remainder theorem can be generalized to any commutative ring, using coprime ideals. Given two randomly chosen integers

1024-421: A , 0) = gcd(0, a ) = | a | . This case is important as the terminating step of the Euclidean algorithm . The above definition is unsuitable for defining gcd(0, 0) , since there is no greatest integer n such that 0 × n = 0 . However, zero is its own greatest divisor if greatest is understood in the context of the divisibility relation, so gcd(0, 0) is commonly defined as 0 . This preserves

1088-422: A 24-by-60 rectangular area can be divided into a grid of: 1-by-1 squares, 2-by-2 squares, 3-by-3 squares, 4-by-4 squares, 6-by-6 squares or 12-by-12 squares. Therefore, 12 is the greatest common divisor of 24 and 60. A 24-by-60 rectangular area can thus be divided into a grid of 12-by-12 squares, with two squares along one edge ( 24/12 = 2 ) and five squares along the other ( 60/12 = 5 ). The greatest common divisor

1152-409: A greatest common divisor computation is needed anyway to ensure the fraction is actually irreducible. Every rational number has a unique representation as an irreducible fraction with a positive denominator (however ⁠ 2 / 3 ⁠ = ⁠ −2 / −3 ⁠ although both are irreducible). Uniqueness is a consequence of the unique prime factorization of integers, since ⁠

1216-665: A positive coprime pair with m > 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, 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

1280-517: A related problem (EUGCD, determining the remainder sequence arising during the Euclidean algorithm) is NC-equivalent to the problem of integer linear programming with two variables; if either problem is in NC or is P-complete , the other is as well. Since NC contains NL , it is also unknown whether a space-efficient algorithm for computing the GCD exists, even for nondeterministic Turing machines. Although

1344-417: A set of integers is pairwise coprime, which means that a and b 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. 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

SECTION 20

#1732858277231

1408-424: A time of T ( n ) , then the fastest known algorithm for greatest common divisor has a complexity O ( T ( n ) log n ) . This implies that the fastest known algorithm has a complexity of O ( n (log n ) ) . Previous complexities are valid for the usual models of computation , specifically multitape Turing machines and random-access machines . The computation of the greatest common divisors belongs thus to

1472-414: A tree of positive coprime pairs ( m , n ) (with m > n ) is by means of two generators f : ( m , n ) → ( m + n , n ) {\displaystyle f:(m,n)\rightarrow (m+n,n)} and g : ( m , n ) → ( m + n , m ) {\displaystyle g:(m,n)\rightarrow (m+n,m)} , starting with

1536-425: A unique representation as an irreducible fraction is utilized in various proofs of the irrationality of the square root of 2 and of other irrational numbers. For example, one proof notes that if √ 2 could be represented as a ratio of integers, then it would have in particular the fully reduced representation ⁠ a / b ⁠ where a and b are the smallest possible; but given that ⁠

1600-436: Is O ( n ) . This means that the computation of greatest common divisor has, up to a constant factor, the same complexity as the multiplication. However, if a fast multiplication algorithm is used, one may modify the Euclidean algorithm for improving the complexity, but the computation of a greatest common divisor becomes slower than the multiplication. More precisely, if the multiplication of two integers of n bits takes

1664-439: Is n = log a + log b , and the complexity is thus Lehmer's algorithm is based on the observation that the initial quotients produced by Euclid's algorithm can be determined based on only the first few digits; this is useful for numbers that are larger than a computer word . In essence, one extracts initial digits, typically forming one or two computer words, and runs Euclid's algorithms on these smaller numbers, as long as it

1728-398: Is 6/ π , which is about 61% (see § Probability of coprimality , below). Two natural numbers a and b are coprime if and only if the numbers 2 – 1 and 2 – 1 are coprime. As a generalization of this, following easily from the Euclidean algorithm in base n > 1 : A set of integers S = { a 1 , a 2 , … ,

1792-770: Is superpolynomial ). ∑ k = 1 n gcd ( k , n ) = ∑ d | n d ϕ ( n d ) = n ∑ d | n φ ( d ) d = n ∏ p | n ( 1 + ν p ( n ) ( 1 − 1 p ) ) {\displaystyle \sum _{k=1}^{n}\gcd(k,n)=\sum _{d|n}d\phi \left({\frac {n}{d}}\right)=n\sum _{d|n}{\frac {\varphi (d)}{d}}=n\prod _{p|n}\left(1+\nu _{p}(n)\left(1-{\frac {1}{p}}\right)\right)} where ν p ( n ) {\displaystyle \nu _{p}(n)}

1856-617: Is 1, 2, 3, 6, 9, 18, 27, 54. Similarly, the divisors of 24 are 1, 2, 3, 4, 6, 8, 12, 24. The numbers that these two lists have in common are the common divisors of 54 and 24, that is, Of these, the greatest is 6, so it is the greatest common divisor : Computing all divisors of the two numbers in this way is usually not efficient, especially for large numbers that have many divisors. Much more efficient methods are described in § Calculation . Two numbers are called relatively prime, or coprime , if their greatest common divisor equals 1 . For example, 9 and 28 are coprime. For example,

1920-440: Is a fraction in which the numerator and denominator are integers that have no other common divisors than 1 (and −1, when negative numbers are considered). In other words, a fraction ⁠ a / b ⁠ is irreducible if and only if a and b are coprime , that is, if a and b have a greatest common divisor of 1. In higher mathematics , " irreducible fraction " may also refer to rational fractions such that

1984-553: Is a "smaller" coprime pair with m > n . {\displaystyle m>n.} This process of "computing the father" can stop only if either a = 2 b {\displaystyle a=2b} or a = 3 b . {\displaystyle a=3b.} In these cases, coprimality, implies that the pair is either ( 2 , 1 ) {\displaystyle (2,1)} or ( 3 , 1 ) . {\displaystyle (3,1).} Another (much simpler) way to generate

Coprime integers - Misplaced Pages Continue

2048-430: 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 gcd(4, 6) = 2 ). The concept of pairwise coprimality is important as a hypothesis in many results in number theory, such as

2112-399: Is a variant of Euclid's algorithm that is specially adapted to the binary representation of the numbers, which is used in most computers . The binary GCD algorithm differs from Euclid's algorithm essentially by dividing by two every even number that is encountered during the computation. Its efficiency results from the fact that, in binary representation, testing parity consists of testing

2176-409: Is an entire function in the variable b for all positive integers a where c d ( k ) is Ramanujan's sum . The computational complexity of the computation of greatest common divisors has been widely studied. If one uses the Euclidean algorithm and the elementary algorithms for multiplication and division, the computation of the greatest common divisor of two integers of at most n bits

2240-479: Is an irreducible fraction because 4 and 3 have no common factors other than 1. The original fraction could have also been reduced in a single step by using the greatest common divisor of 90 and 120, which is 30. As 120 ÷ 30 = 4 , and 90 ÷ 30 = 3 , one gets Which method is faster "by hand" depends on the fraction and the ease with which common factors are spotted. In case a denominator and numerator remain that are too large to ensure they are coprime by inspection,

2304-409: Is based on the fact that, given two positive integers a and b such that a > b , the common divisors of a and b are the same as the common divisors of a – b and b . So, Euclid's method for computing the greatest common divisor of two positive integers consists of replacing the larger number with the difference of the numbers, and repeating this until the two numbers are equal: that

2368-470: Is divisible by 7. Hence the probability that two numbers are both divisible by p is ⁠ 1 p 2 , {\displaystyle {\tfrac {1}{p^{2}}},} ⁠ and the probability that at least one of them is not is ⁠ 1 − 1 p 2 . {\displaystyle 1-{\tfrac {1}{p^{2}}}.} ⁠ Any finite collection of divisibility events associated to distinct primes

2432-408: Is guaranteed that the quotients are the same with those that would be obtained with the original numbers. The quotients are collected into a small 2-by-2 transformation matrix (a matrix of single-word integers) to reduce the original numbers. This process is repeated until numbers are small enough that the binary algorithm (see below) is more efficient. This algorithm improves speed, because it reduces

2496-636: Is led to guess that the probability that two numbers are coprime is given by a product over all primes, Here ζ refers to the Riemann zeta function , the identity relating the product over primes to ζ (2) is an example of an Euler product , and the evaluation of ζ (2) as π /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

2560-410: Is mutually independent. For example, in the case of two events, a number is divisible by primes p and q if and only if it is divisible by pq ; the latter event has probability ⁠ 1 p q . {\displaystyle {\tfrac {1}{pq}}.} ⁠ If one makes the heuristic assumption that such reasoning can be extended to infinitely many divisibility events, one

2624-406: Is their greatest common divisor. For example, to compute gcd(48,18) , one proceeds as follows: So gcd(48, 18) = 6 . This method can be very slow if one number is much larger than the other. So, the variant that follows is generally preferred. A more efficient method is the Euclidean algorithm , a variant in which the difference of the two numbers a and b is replaced by the remainder of

Coprime integers - Misplaced Pages Continue

2688-431: Is to indicate that their greatest common divisor is one, by the formula gcd( a , b ) = 1 or ( a , b ) = 1 . In their 1989 textbook Concrete Mathematics , Ronald Graham , Donald Knuth , and Oren Patashnik proposed an alternative notation a ⊥ b {\displaystyle a\perp b} to indicate that a and b are relatively prime and that the term "prime" be used instead of coprime (as in

2752-407: Is unique up to multiplication of denominator and numerator by the same invertible element. In the case of the rational numbers this means that any number has two irreducible fractions, related by a change of sign of both numerator and denominator; this ambiguity can be removed by requiring the denominator to be positive. In the case of rational functions the denominator could similarly be required to be

2816-418: Is useful for reducing fractions to the lowest terms . For example, gcd(42, 56) = 14 , therefore, The least common multiple of two integers that are not both zero can be computed from their greatest common divisor, by using the relation Greatest common divisors can be computed by determining the prime factorizations of the two numbers and comparing factors. For example, to compute gcd(48, 180) , we find

2880-601: 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 . Two ideals A and B in a commutative ring R are called coprime (or comaximal ) if A + B = R . {\displaystyle A+B=R.} This generalizes Bézout's identity : with this definition, two principal ideals (

2944-402: The Euclidean division (also called division with remainder ) of a by b . Denoting this remainder as a mod b , the algorithm replaces ( a , b ) with ( b , a mod b ) repeatedly until the pair is ( d , 0) , where d is the greatest common divisor. For example, to compute gcd(48,18), the computation is as follows: This again gives gcd(48, 18) = 6 . The binary GCD algorithm

3008-570: The GCD of 8 and 12 is 4, that is, gcd(8, 12) = 4 . In the name "greatest common divisor", the adjective "greatest" may be replaced by "highest", and the word "divisor" may be replaced by "factor", so that other names include highest common factor , etc. Historically, other names for the same concept have included greatest common measure . This notion can be extended to polynomials (see Polynomial greatest common divisor ) and other commutative rings (see § In commutative rings below). The greatest common divisor (GCD) of integers

3072-429: The algorithm stops, the result is correct. The algorithm stops eventually, since each steps divides at least one of the operands by at least 2 . Moreover, the number of divisions by 2 and thus the number of subtractions is at most the total number of digits. Example: ( a , b , d ) = (48, 18, 0) → (24, 9, 1) → (12, 9, 1) → (6, 9, 1) → (3, 9, 1) → (3, 3, 1) ; the original GCD is thus the product 6 of 2 = 2 and

3136-439: The class of problems solvable in quasilinear time . A fortiori , the corresponding decision problem belongs to the class P of problems solvable in polynomial time. The GCD problem is not known to be in NC , and so there is no known way to parallelize it efficiently; nor is it known to be P-complete , which would imply that it is unlikely to be possible to efficiently parallelize GCD computation. Shallcross et al. showed that

3200-420: The entire set of lengths are pairwise coprime. This concept can be extended to other algebraic structures than ⁠ Z ; {\displaystyle \mathbb {Z} ;} ⁠ for example, polynomials whose greatest common divisor is 1 are called coprime polynomials . Reduced fraction An irreducible fraction (or fraction in lowest terms , simplest form or reduced fraction )

3264-418: The first point by Euclid's lemma , which states that if a prime number p divides a product bc , then p divides at least one of the factors b, c . As a consequence of the first point, if a and b are coprime, then so are any powers a and b . If a and b are coprime and a divides the product bc , then a divides c . This can be viewed as a generalization of Euclid's lemma. The two integers

SECTION 50

#1732858277231

3328-437: The greatest common divisor, the Euclidean algorithm or prime factorization can be used. The Euclidean algorithm is commonly preferred because it allows one to reduce fractions with numerators and denominators too large to be easily factored. In the first step both numbers were divided by 10, which is a factor common to both 120 and 90. In the second step, they were divided by 3. The final result, ⁠ 4 / 3 ⁠ ,

3392-436: The number of operations on very large numbers, and can use hardware arithmetic for most operations. In fact, most of the quotients are very small, so a fair number of steps of the Euclidean algorithm can be collected in a 2-by-2 matrix of single-word integers. When Lehmer's algorithm encounters a quotient that is too large, it must fall back to one iteration of Euclidean algorithm, with a Euclidean division of large numbers. If

3456-444: The numerator and the denominator are coprime polynomials . Every rational number can be represented as an irreducible fraction with positive denominator in exactly one way. An equivalent definition is sometimes useful: if a and b are integers, then the fraction ⁠ a / b ⁠ is irreducible if and only if there is no other equal fraction ⁠ c / d ⁠ such that | c | < |

3520-478: The ones above can be formalized by using the notion of natural density . For each positive integer N , let P N be the probability that two randomly chosen numbers in { 1 , 2 , … , N } {\displaystyle \{1,2,\ldots ,N\}} are coprime. Although P N will never equal 6/ π exactly, with work one can show that in the limit as N → ∞ , {\displaystyle N\to \infty ,}

3584-454: The other hand, ⁠ 2 / 4 ⁠ is reducible since it is equal in value to ⁠ 1 / 2 ⁠ , and the numerator of ⁠ 1 / 2 ⁠ is less than the numerator of ⁠ 2 / 4 ⁠ . A fraction that is reducible can be reduced by dividing both the numerator and denominator by a common factor. It can be fully reduced to lowest terms if both are divided by their greatest common divisor . In order to find

3648-483: The other tree starting from (3, 1) (for odd–odd pairs). The children of each vertex ( m , n ) are generated as follows: This scheme is exhaustive and non-redundant with no invalid members. This can be proved by remarking that, if ( a , b ) {\displaystyle (a,b)} is a coprime pair with a > b , {\displaystyle a>b,} then In all cases ( m , n ) {\displaystyle (m,n)}

3712-505: The prime factorizations 48 = 2  · 3 and 180 = 2  · 3  · 5 ; the GCD is then 2  · 3  · 5 = 2  · 3  · 5 = 12 The corresponding LCM is then 2  · 3  · 5 = 2  · 3  · 5 = 720. In practice, this method is only feasible for small numbers, as computing prime factorizations takes too long. The method introduced by Euclid for computing greatest common divisors

3776-473: The probability P N approaches 6/ π . More generally, the probability of k randomly chosen integers being setwise coprime is ⁠ 1 ζ ( k ) . {\displaystyle {\tfrac {1}{\zeta (k)}}.} ⁠ All pairs of positive coprime numbers ( m , n ) (with m > n ) can be arranged in two disjoint complete ternary trees , one tree starting from (2, 1) (for even–odd and odd–even pairs), and

3840-627: The problem is not known to be in NC , parallel algorithms asymptotically faster than the Euclidean algorithm exist; the fastest known deterministic algorithm is by Chor and Goldreich , which (in the CRCW-PRAM model) can solve the problem in O ( n /log n ) time with n processors. Randomized algorithms can solve the problem in O ((log n ) ) time on exp ⁡ ( O ( n log ⁡ n ) ) {\displaystyle \exp \left(O\left({\sqrt {n\log n}}\right)\right)} processors (this

3904-413: The ratio of two integers is false. The notion of irreducible fraction generalizes to the field of fractions of any unique factorization domain : any element of such a field can be written as a fraction in which denominator and numerator are coprime, by dividing both by their greatest common divisor. This applies notably to rational expressions over a field. The irreducible fraction for a given element

SECTION 60

#1732858277231

3968-423: The right-most digit, and dividing by two consists of removing the right-most digit. The method is as follows, starting with a and b that are the two positive integers whose GCD is sought. Step 1 determines d as the highest power of 2 that divides a and b , and thus their greatest common divisor. None of the steps changes the set of the odd common divisors of a and b . This shows that when

4032-482: The root ( 2 , 1 ) {\displaystyle (2,1)} . The resulting binary tree, the Calkin–Wilf tree , is exhaustive and non-redundant, which can be seen as follows. Given a coprime pair one recursively applies f − 1 {\displaystyle f^{-1}} or g − 1 {\displaystyle g^{-1}} depending on which of them yields

4096-420: The usual identities for GCD, and in particular Bézout's identity , namely that gcd( a , b ) generates the same ideal as { a , b } . This convention is followed by many computer algebra systems . Nonetheless, some authors leave gcd(0, 0) undefined. The GCD of a and b is their greatest positive common divisor in the preorder relation of divisibility . This means that the common divisors of

#230769