企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 10.1 Number Theory Review We review some basic elements of number theory. ### 10.1.1 Composite and Prime Numbers The set ![](https://box.kancloud.cn/8c92ec0bf0a37caf90a64d9052962c4a_223x22.jpg) is called the set of ***integers***. For any two integers *n, h* ∊ *Z*, we say *h* ***divides*** *n* denoted *h*|*n*, if there is some integer *k* such that *n* = *kh*. If *h*|*n*, we also say *n* is ***divisible*** by *h, n* is a ***multiple*** of *h*, and *n* is a ***divisor*** or ***factor*** of *n*. Example 10.1**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**We have that 4|20 since 20 = (5) (4). The interger 3 does not divide 20 since there is no integer *k* such that 20 = (*k*) (3). **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Example 10.2**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The divisors of 12 are ![](https://box.kancloud.cn/722c2bc642239c1e24e7007b8748022a_174x20.jpg) **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** An integer *n* < 1 whose only positive divisors are 1 and *n* is a called a ***prime number*** or simple a ***prime***. A prime number has no factors. An integer *n* > 1 that is not prime is called a ***composite number***. A composite number has at least one factor. Example 10.3**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The first 10 primes are ![](https://box.kancloud.cn/c435532db628e67b826a41a7d0f8c50a_278x21.jpg) **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Example 10.4**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The integer 12 is composite because it has the divisors 2, 3, 4, and 6. The integer 4 is composite because it has the divisor 2. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ### 10.1.2 Greatest Common Divisor If *h|n* and *h|m*, then *h* is called a ***common divisor*** of *n* and *m*. If *n* and *m* are not both zero, the ***greatest common divisor*** of *n* and *m*, denoted gcd(*n, m*), is the largest integer that divides both of them. Example 10.5**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The positive divisors of 24 are **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/1a8bf201fab3fcc86927fa6cd469d4b8_224x20.jpg) and the positive divisors of 30 are ![](https://box.kancloud.cn/e7455194a854d4a7e53b010504570144_237x22.jpg) So the common positive divisors of 24 and 30 are ![](https://box.kancloud.cn/6e77d7c79d78b5dc869179f4bb729627_117x21.jpg) and the value of gcd(24, 30) is 6. We have the following theorems concerning common divisors: Theorem 10.1**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**If *h|n* and *h|m*, then for any integers *i* and *j* **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/d87e253b0e54e246eed305e63f5c552b_104x23.jpg) Proof: Since *h|n* and *h|m*, there exist integers *k* and *l* such that *n* = *kh* and *m* = *lh*. Therefore, ![](https://box.kancloud.cn/32dd1491bcd3da29460ae84f9464f151_271x22.jpg) which means *h*| (*in* + *jm*). Before proceeding, we need more definitions. For any two integers *n* and *m*, where *m* ≠ 0, the ***quotient*** *q* of *n* divided by *m* is given by ![](https://box.kancloud.cn/423552bebc9cdaccb13d9e6500523985_94x22.jpg) and the ***remainder*** *r* of dividing *n* by *m* is given by ![](https://box.kancloud.cn/5dd534f061adfac5e88b1c90e70e5684_98x16.jpg) The remainder is denoted *n* mod *m*. It is not hard to see that if *m* > 0 then 0 ≤ *r* < *m*, and if *m* < 0 then *m* < *r* ≤ 0. So we have ![](https://box.kancloud.cn/2d43af4a691bde09d6f0b289ee7e4be5_400x47.jpg) The **division algorithm** says not only that the integers *q* and *r* in Equality 10.1 exist but also that they are unique. Example 10.6**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The following table shows some quotients and remainders: **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** n m q=∟n/m⌟ r=n–qm 23 5 ∟23/5⌟=4 23–(4)(5)=3 –23 5 ∟–23/5⌟=–5 –23–(–5)(5)=2 23 –5 ∟23/–5⌟=–5 23–(–5)(–5)=–2 –23 –5 ∟23/–5⌟=4 –23–(4)(–5)=–3 20 5 ∟20/5⌟=4 20–(4)(5)=3 Theorem 10.2**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**Let *n* and *m* be integers, not both 0, and let **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/d8a3748225fee724e21316a5d93603e2_400x19.jpg) That is, *d* is the smallest positive linear combination of *n* and *m*. Then ![](https://box.kancloud.cn/18e078d534b554b2851343be1e6cf469_115x21.jpg) Proof: Let *i* and *j* be the integers that yield the minimal value *d*. That is, *d* = *in* + *jm*. Furthermore, let *q* and *r* be the quotient and remainder respectively, of dividing *n* by *d*. Then owing to Equality 10.1 and the fact that *d* is positive, ![](https://box.kancloud.cn/9632c697b7f2e07d6d8487ade7fed712_266x21.jpg) We therefore have ![](https://box.kancloud.cn/8c8f04d0cd7341c58bcb7ba198a0f391_202x75.jpg) which means that *r* is a linear combination of *n* and *m*. Since *d* is the smallest positive linear combination of *n* and *m* and *r* < *d*, we conclude *r* = 0, whichmeans *d|n*. Similarly, *d|m*. Therefore, *d* is a common divisor of *m* and *n*, which means ![](https://box.kancloud.cn/dcedae78da06e5cbe67ed7d40ddbc23a_115x22.jpg) Since the gcd(*n, m*) divides both *n* and *m*, and *d* = *in* + *jm*, [Theorem 10.1](LiB0088.html#1213) implies gcd(*n, m*)|*d*. We conclude ![](https://box.kancloud.cn/2dfffdf1b2c06c19493484c5cb3eab94_116x21.jpg) Combining these last two inequalities, we have *d* = gcd(*n, m*). Example 10.7**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**We have that gcd(12, 8) = 4, and **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/1dce5de07a7fa4ebc5b74c23f212939b_152x22.jpg) Corollary 10.1**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**Suppose *n* and *m* are integers, not both 0. Then every common divisor of *n* and *m* is a divisor of gcd(*n, m*). That is, if *h|n* and *h|m*, then **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/d7c64c0db75b7f190bc8710c11ed20b2_101x22.jpg) Proof: By the preceding theorem, gcd(*n, m*) is a linear combination of *n* and *m*. The proof now follows from [Theorem 10.1](LiB0088.html#1213). Example 10.8**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**As shown in [Example 10.5](LiB0088.html#1219), the common positive divisors of 24 and 30 are **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/745343b2897404b3aefcc5418eeab34b_116x20.jpg) and the value of gcd(24, 30) is 6. As the previous corollary implies, 1, 2, 3, and 6 all divide 6. Theorem 10.3**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**Suppose we have integers *n* ≥ 0 and *m* > 0. If we let *r* = *n*mod*m*, then **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/765e4f0e6ed3f38ab4cb2f7e7df73998_179x22.jpg) If *n* = 0, *r* = *m* and the equality obviously holds. Otherwise, we will show that gcd(*n, m*) and gcd(*m, r*) each divide each other. It is left as an exercise to show that two positive integers divide each other if and only if they are equal, whichwill complete the proof of the theorem. First we show gcd(*n, m*)| gcd(*m, r*). If we let *d*′ = gcd(*n,m*) then *d*′ |*n* and *d*′|*m*. Furthermore, ![](https://box.kancloud.cn/bb78b4e0fc279d376507cd7652b33d62_99x17.jpg) where *q* is the quotient of *n* divided by *m*, which means *r* is a linear combination of *n* and *m*. [Theorem 10.1](#ch10ex06) therefore implies *d*’|*r*. Since *d*’|*m* and *d*’|*r*, [Corollary 10.1](#ch10ex10) implies ![](https://box.kancloud.cn/21c6cc2b030ece6350a6e3a402bada6d_103x23.jpg) which completes the proof of this direction. Next show gcd(*m, r*)| gcd(*n, m*). If we let *d*″ = gcd(*m, r*), then *d*″|*m* and *d*″*r*. Furthermore, ![](https://box.kancloud.cn/56b9c381a7ab057555a6916e6c992796_97x17.jpg) where *q* is the quotient of *n* divided by *m*, which means *n* is a linear combination of *m* and *r*. [Theorem 10.1](#ch10ex06) therefore implies *d*″|*n*. Since *d*″|*m* and *d*″|*n*, [Corollary 10.1](#ch10ex10) implies ![](https://box.kancloud.cn/2e49ab563cd42d5f8fa5b2bf1c416fe3_109x23.jpg) which completes the proof of this direction. Example 10.9**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**According to the previous theorem, **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/f6dab6b01205a1759de0ff96d86b4e23_194x22.jpg) because 16 = 64 mod 24. We can continue in this manner to determine gcd(64, 24). That is, ![](https://box.kancloud.cn/50aefd4bafb7f6fa62daafac33fc8b46_198x99.jpg) ### 10.1.3 Prime Factorization Every integer greater than one can be written as a unique product of primes. We next develop theory that proves this assertion. Two integers *n* and *h*, not both zero, are called ***relatively prime*** if gcd(*n,h*) = 1. Example 10.10**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The integers 12 and 25 are relatively prime because gcd(12, 25) = 1. The integers 12 and 15 are not relatively prime because gcd(12, 15) = 3. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Theorem 10.4**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**If *h* and *m* are relatively prime, and *h* divides *nm*, then *h* divides *n*. That is, *gcd*(*h,m*) = 1 and *h|nm* implies *h|n*. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Proof: [Theorem 10.2](#ch10ex08) implies there are integers *i* and *j* such that ![](https://box.kancloud.cn/f50dfbb1114bf7aeb61878d48a766070_102x20.jpg) Multiplying this equality by *n* yields ![](https://box.kancloud.cn/49f6d92ff1ba3b2620e88fc7d6f92bb7_159x21.jpg) Clearly, *h* divides the first term on the left-hand side of this equality, and, since *h|nm*, *h* also divides the second term. Therefore, *h* divides the left-hand side, which means *h* divides *n*. Example 10.11**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The integers 9 and 4 are relatively prime, 9|72, and 72 = 18 × 4. As the previous theorem implies, 9|18. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Corollary 10.2**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**Given integers *n, m*, and prime integer *p*, if *p|nm*, then *p|n* or *p|m* (inclusive). **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Proof: The proof follows easily from [Theorem 10.4](#ch10ex15). The theorem that follows is called the ***unique factorization theorem*** and the ***fundamental theorem of arithmetic***. Theorem 10.5**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**Every integer *n* ≥ 1 has a unique factorization as a product of prime numbers. That is, **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/65af82a1d39f6dedcf4f46a7799b47a2_143x30.jpg) where *p*1 < *p*2 < … < *pj* are primes, and this representation of *n* is unique. The integer *ki* is called the ***order*** of *pi* in *n*. Proof: We use induction to prove such a representation exists. Induction base: We have 2 = 21. Induction hypothesis: Suppose all integers *m* such that 2 ≤ *m* < *n* can be written as a product of prime numbers. Induction step: If *n* is prime, then *n* = *n*1 is our representation. Otherwise, *n* is composite, which means there exists integers *m, h* > 1 such that ![](https://box.kancloud.cn/12d1b6c7cf2ab7f0292e2797910f38e8_69x17.jpg) Clearly *m, h* < *n*. Therefore, by the induction hypothesis, *m* and *h* can each be written as a product of primes. That is, ![](https://box.kancloud.cn/fa422fbf93e969fc14e2561cbfe11d32_146x59.jpg) Since *n* = *mh*, ![](https://box.kancloud.cn/33df2ccc4a6e86d1ee7a10efe009a2f6_232x29.jpg) We obtain our desired representation by grouping primes that are equal and arranging the terms according to increasing values of the primes. This completes the induction proof. The fact that the product is unique follows from [Corollary 10.2](#ch10ex17) and is left as an exercise. Example 10.12**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**We have that **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ![](https://box.kancloud.cn/4cd38844abdecdd04e86565c46dfdf55_133x23.jpg) The previous theorem says the representation on the right-hand side of this equality is unique. Theorem 10.6**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The gcd(*n, m*) is a product of the primes that are common to *n* and *m*, where the power of each prime in the product is the smaller of its orders in *n* and *m*. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Proof: The proof is left as an exercise. Example 10.13**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**We have 300 = 22 × 31 × 52 and 1,125 = 32 × 53. So gcd (300, 1,125) = 20 × 31 × 52 75. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** ### 10.1.4 Least Common Multiple A concept similar to that of the greatest common divisor is that of the least common multiple. If *n* and *m* are both nonzero, the ***least common multiple*** of *n* and *m*, denoted lcm(*n, m*), is the smallest positive integer that they both divide. Example 10.14**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The lcm(6,9) = 18 because 6|18, 9|18, and there is no smaller positive integer that they both divide. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Theorem 10.7**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**The lcm(*n, m*) is a product of the primes that are common to *n* and *m*, where the power of each prime in the product is the larger of its orders in *n* and *m*. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)** Proof: The proof is left as an exercise. Example 10.15**![Start example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**We have 12 = 22 × 31 and 45 = 32 × 51. So lcm(12, 45) = 22 × 32 × 51 = 180. **![End example](https://box.kancloud.cn/e95df9d604ab2d89febe370ae4d88fb1_1x1.gif)**