1 of 22

PRIME NUMBERS �

312706023 何忻

4.3

The Division Algorithm:

2 of 22

OUTLINE

Prime & Composite number

Division algorithms

Digit represent in computer

3 of 22

DEFINITION 4.1

  • If a, b ∈ Z and b ≠ 0, we say that b divides a, and write b|a, if there is an integer n such that a = bn.
  • When this occurs we say that b is a divisor of a, or a is a multiple of b. ( ba除數 ab乘數

  • When ab = 0 for a, b ∈ Z, then either a = 0 or b = 0, and we say that Z has no proper divisor of 0.

(不存在除了自己1 之外的因數)

a mod b = 0_

1

4 of 22

THEOREM 4.3

  • For a, b, c ∈ Z

(a) 1|a and a|0.

(b) [(a|b) ∧ (b|a)] ⟹ a = ± b.

(c) [(a|b) ∧ (b|c)] ⟹ a|c.

(d) a|b a|bx, for all x ∈ Z.

(e) If x = y + z, for x, y, z ∈ Z, and a divides two of the three integer x, y, z, then a divides the remaining integer.

(f) [(a|b) ∧ (a|c)] ⟹ a|(bx + cy), for all 𝑥, y ∈ Z.

(The expression bx + cy is called a linear combination of b, c.)

(g) For 1 ≤ i n, let ci ∈ Z. If a divides each ci , then a|( c1x1+c2x2 + + cnxn ), where 𝑥𝑖 ∈ Z , 1 ≤ i n.

2

5 of 22

  • [(a|b) ∧ (a|c)] ⟹ a|(bx + cy), for all 𝑥, y ∈ Z.

(The expression bx + cy is called a linear combination of b, c.)

3

1. If a|b and a|c, then b = am and c = an, for some m, n ∈ Z.

2.  So bx + cy = (am)x + (an)y = a(mx + ny)

  • Associative Law of Mulitplication
  • Distributive Law of Multiplication over Addition

Part (f):

Proof

Since bx + cy = a(mx + ny), with mx + ny ∈ Z

⟹ It follows that a|(bx + cy)

6 of 22

EXAMPLE 4.23

  • Do there exist integers x, y, z so that 6x+9y+15z=107?

4

Step 1: Since 3|6 and 3|9 and 3|15

Step 2: 3 is a divisor of 6x + 9y + 15z

Step 3: 3 is a divisor of 107 (?)

(g) For 1 ≤ i n, let ci ∈ Z. If a divides each ci ,

then a|( c1x1+c2x2 + + cnxn ), where 𝑥𝑖 ∈ Z , 1 ≤ i n.

NO!

So there doesn’t exist such integers x, y, z

7 of 22

EXAMPLE 4.24

  • Let a, b ∈ Z so that 17 | (2a+3b). Prove 17 | (9a+5b)

5

Step 1: 17 | (2a + 3b) ⟹ 17 | (−4)∗(2a + 3b)

Step 2: 17 | (17a + 17b)

Step 3: 17 | [(17a + 17b) + (−4)∗(2a + 3b)]

⟹ 17 | 9a + 5b

(d) a|b a|bx, for all x ∈ Z.

(f) [(a|b) ∧ (a|c)] ⟹ a|(bx + cy), for all 𝑥, y ∈ Z.

(e) If x = y + z, for x, y, z ∈ Z, and a divides two of the three integer x, y, z, then a divides the remaining integer.

8 of 22

 

LEMMA 4.1

If n ∈ 𝐙+ and n is composite,

then there is a prime p such that p|n

Proof

(d) a|b a|bx, for all x ∈ Z.

與 m 的假設相互矛盾 ⟹ 可知 S = ∅

必定存在質數 p 可整除 n

6

9 of 22

  • There are infinitely many primes.

 

THEOREM 4.4 EUCLID

Proof

但不可能有pj 可整除1 ⟹ 與假設相互矛盾

有無限多的質數存在

(e) If x = y + z, for x, y, z ∈ Z, and a divides two of the three integer x, y, z, then a divides the remaining integer.

By LEMMA 4.1

7

10 of 22

  • If a, b ∈ Z, with b > 0, then there exist unique q, r ∈ Z

with a = qb + r, 0 ≤ r < b.

THEOREM 4.5 THE DIVISION ALGORITHM

UNIQUENESS唯一性

EXISTENCE

存在性

  • 前提:If b|a the result follows with r = 0

⟹ so consider the case b does not divide a.

8

11 of 22

Proof

Existence 存在性

Step 1: Let S = {atb| t ∈ Z, a tb > 0} ⊂ 𝐙+.

(a) If a > 0, let t = 0 ⟹ a ∈ S and S ≠ ∅

(b) If a ≤ 0, let t = a – 1 ⟹ atb

= a – (a – 1)b = a(1 – b) + b

Step 2: Because b ≥ 1 ⟹ (1 – b) ≤ 0 ⟹ a(1 – b) ≥ 0

atb = a(1 – b) + b > 0 and S ≠ ∅.

Hence, for any a ∈ Z, S is a nonempty subset of 𝐙+.

By WOP, S has a least element r, where 0 < r = aqb, for some q ∈ Z.

(c) If r = b, then a = (q+1)b b|a.

(d) If r > b, then r = b + c, for some c ∈ 𝐙+.

a qb = r = b + c c = a – (q+1)b S

 

This now establishes a quotient q and remainder r, 0 ≤ r < b, for the theorem.

與初始前提相互矛盾

符合形式 atb

9

12 of 22

Proof

Uniqueness 唯一性

Step 1: Suppose there are q1, q2, r1, r2 ∈ Z

with a = q1 b + r1 , 0 ≤ r1 < b and a = q2 b + r2, 0 ≤ r2 < b

Step 2: Then q1 b + r1 = q2 b + r2

b ∙ |q1q2 | = |r2r1| < b

(∵ 0 ≤ r1 , r2 < b )

 

10

13 of 22

  • Calculate 4 * 7

Step 1: 2 * 7 = 7 + 7 = 14

Step 2: 3 * 7 = (2 + 1)* 7 = 2 * 7 + 1* 7

= (7 + 7 ) + 7 = 21

Step 3: 4 * 7 = (3 + 1)* 7 = 3 * 7 + 1* 7

= ((7 + 7 ) + 7) + 7 = 21 + 7= 28

EXAMPLE 4.26

Repeated addition

11

14 of 22

Step 1: 37 - 8 = 29 ≥ 8

Step 2: 29 - 8 = (37 - 8) - 8 = 37 - (2・8) = 21 ≥ 8

Step 3: 21 - 8 = ((37 - 8) - 8) - 8 = 37 - (3・8) = 13 ≥ 8

Step 4: 13 - 8 = (((37 - 8) - 8) - 8) -8 = 37 - (4・8)

= 5 < 8

EXAMPLE 4.26

Repeated subtraction

 

q = 4, r = 5

12

15 of 22

  • Write 6137 in the octal system (base 8)

6137

8

767

8

95

11

8

1

8

0

1

7

7

3

1

6137 = (13771)8

Remainders

Nonnegative integers r0, r1, r2, … rk, with 0 < rk < 8

⟹ such that 6137 = (rk r2r1r0)8

r4

r3

r2

r1

r0

 

Remainders

Concept

 

以此類推

EXAMPLE 4.27

8

13

16 of 22

  • Write 13,874,945 (base 16)

13,874,945

16

867,184

16

54,199

16

3,387

16

211

16

1

0

7

11 (= B)

3

13 (= D)

13

16

0

EXAMPLE 4.28

Remainders

r4

r3

r2

r1

r0

r5

13,874,945 = (D3B701)16

14

17 of 22

  • Converting between base 2 and base 16

1010

0001

0011

1111

A

1

3

F

EXAMPLE 4.28

(A13F)16 = (1010000100111111)2

15

18 of 22

EXAMPLE 4.29

1’s complement of |n|

2’s complement of n

Replace each 0/1 in the binary represented of |n| by 1/0

Add 1 too the result in 1’s complement

Step 1: Start with binary representation of 6.

Step 2: Interchange the 0/1

⟹ the result is 1’s complement of 0110.

Step 3: Add 1 to be the prior result.

6 ⟹ 0110

1001

1010

  • Obtain the 2’s complement of -6

16

19 of 22

EXAMPLE 4.29

  • obtain the four-bit pattern for the value -8 ≤ n ≤ -1

非負整數始於0

非負整數的 2 補數

= 直接轉換成二進制

負整數的 2 補數

⟹ 取其絕對值1 補數

再加上 1

17

20 of 22

Step 1: 33 – 15 = 33 + (-15)

Step 2: 33 = (00100001)2

Step 3: 15 = (00001111)2

Step 4: -15 = 11110000 + 00000001 = 11110001

Step 5:

00100001

11110001

+

100010010

Discarded

EXAMPLE 4.30

  • Calculate 33 – 15 (base 2)

Step 6: (00010010)2 =18

18

21 of 22

01110101

01011000

+

11001101

117

88

+

EXAMPLE 4.30

  • Overflow error when adding 2 numbers

It means the ans is negative!

Range of N bits [−2N−1, 2N−1 − 1]

19

22 of 22

 

EXAMPLE 4.31

 

Proof

 

By LEMMA 4.1

 

20