# prime and relatively prime numbers

Post on 30-Dec-2015

43 views

Category:

## Documents

Embed Size (px)

DESCRIPTION

Prime and Relatively Prime Numbers. Divisors: We say that b  0 divides a if a = mb for some m , where a , b and m are integers. b divides a if there is no remainder on division. The notation b | a is commonly used to mean that b divides a . - PowerPoint PPT Presentation

TRANSCRIPT

• Prime and Relatively Prime Numbers Divisors: We say that b 0 divides a if a = mb for some m, where a, b and m are integers.b divides a if there is no remainder on division.The notation b|a is commonly used to mean that b divides a.If b|a, we say that b is a divisor of a.

• Prime and Relatively Prime Numbers (contd) If a|1, then a = 1.If a|b and b|a, then a = b.Any b 0 divides 0.If b|g and b|h, then b|(mg + nh) for arbitrary integers m and n.

• Prime and Relatively Prime Numbers (contd)

• Prime and Relatively Prime Numbers (contd) Table 7.1 Primes under 2000

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199

211 223 227 229 233 239 241 251 257 263 269 271 281 283 293

307 311 313 317 331 337 347 349 449 457 461 463 467 479 487 491 499

401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499

503 509 521 523 541 547 557 563 569 571 577 587 593 599

601 607 613 617 619 631 641 643 647 653 659 661 673 677 683 691

701 709 719 727 733 739 743 751 757 761 769 773 787 797

809 811 821 823 827 829 839 853 857 859 863 877 881 883 887

907 911 919 929 937 941 947 953 967 971 977 983 991 997

1009 1013 1019 1021 1031 1033 1039 1049 1051 1061 1063 1069 1087 1091 1093 1097

1103 1109 1117 1123 1129 1151 1153 1163 1171 1181 1187 1193

1201 1213 1217 1223 1229 1231 1237 1249 1259 1277 1279 1283 1289 1291 1297

1301 1303 1307 1319 1321 1327 1361 1367 1373 1381 1399

1409 1423 1427 1429 1433 1439 1447 1451 1453 1459 1471 1481 1483 1487 1489 1493 1499

1511 1523 1531 1543 1549 1553 1559 1567 1571 1579 1583 1597

1601 1607 1609 1613 1619 1621 1627 1637 1657 1663 1667 1669 1693 1697 1699

1709 1721 1723 1733 1741 1747 1753 1759 1777 1783 1787 1789

1801 1811 1823 1831 1847 1861 1867 1871 1873 1877 1879 1889

1901 1907 1913 1931 1933 1949 1951 1973 1979 1987 1993 1997 1999

• Prime and Relatively Prime Numbers (contd)The above statement is referred to as the prime number theorem, which was proven in 1896 by Hadaward and Poussin.

x

((x)

x/ln x

(((x) ( ln x)/x

103

168

144.8

1.160

104

1229

1085.7

1.132

105

9592

8685.9

1.104

106

78498

74382.4

1.085

107

664579

620420.7

1.071

108

5761455

5428681.0

1.061

109

50847534

48254942.4

1.054

1010

455052512

434294481.9

1.048

• Prime and Relatively Prime Numbers (contd)

• Prime and Relatively Prime Numbers (contd)Whether there exists a simple formula to generate prime numbers?An ancient Chinese mathematician conjectured that if n divides 2n - 2 then n is prime. For n = 3, 3 divides 6 and n is prime. However, For n = 341 = 11 31, n dives 2341 - 2. Mersenne suggested that if p is prime then Mp = 2p - 1 is prime. This type of primes are referred to as Mersenne primes. Unfortunately, for p = 11, M11 = 211 -1 = 2047 = 23 89.

• Prime and Relatively Prime Numbers (contd)Fermat conjectured that if Fn = 22n + 1, where n is a non-negative integer, then Fn is prime. When n is less than or equal to 4, F0 = 3, F1 = 5, F2 = 17, F3 = 257 and F4 = 65537 are all primes. However, F5 = 4294967297 = 641 6700417 is not a prime bumber.n2 - 79n + 1601 is valid only for n < 80.There are an infinite number of primes of the form 4n + 1 or 4n + 3.There is no simple way so far to gererate prime numbers.

• Prime and Relatively Prime Numbers (contd)Factorization of an integer as a product of prime numbersExample: 91 = 7 13; 11011 = 7 112 13.Useful for checking divisibility and relative primality to be discussed later.Factorization is in gereral difficult.

• Prime and Relatively Prime Numbers (contd)Define notation gcd(a,b) to mean the greatest common divisor of a and b. The positive integer c is said to be the gcd of a and b ifc|a and c|bany divisor of a and b is a dividor of c.Equivalently, gcd(a,b) = max[k, such that k|a and k|b]gcd(a,b) = gcd(-a,b) = gcd(a,-b) = gcd(-a,-b) =gcd(|a|,|b|)

• Prime and Relatively Prime Numbers (contd)gcd(a,0) = |a|.Factorization is one possible but in general inefficient way to calculate gcd. Whereas, Euclids algorithm (to be discussed later) is more efficient.Relative primalitythe integers a and b are relatively prime if they have no prime factors in commonor equivalently, their only common factor is 1or equivalently, gcd(a,b) = 1

• Modular Arithmetic

• Modular Arithmetic (contd)Examples:a = 11; n = 7; 11 = 1 7 + 4; r = 4.a = -11; n = 7; -11 = (-2) 7 + 3; r = 3.If a is an integer and n is a positive integer, define a mod n to be the remainder when a is divided by n.Then, a = a/n n + (a mod n);Example: 11 mod 7 = 4; -11 mod 7 = 3.

• Modular Arithmetic (contd)

The modulo operator has the following properties:

1. ab mod n if n|(a-b).

2. (a mod n)(b mod n) implies ab mod n.

3. ab mod n implies ba mod n.

4. ab mod n and bc mod n imply ac mod n.

238 (mod 5)

because

2381553

-115 (mod 8)

because

-115-168(-2)

810 (mod 27)

because

81081273

• Modular Arithmetic (contd)Properties of modular arithmetic operations

Proof of Property 1:Define (a mod n) = ra and (b mod n) = rb. Then a = ra + jn and b = rb + kn for some integers j and k. Then, (a+b) mod n = (ra + jn + rb + kn) mod n = (ra + rb + (j + k)n) mod n = (ra + rb) mod n = [(a mod n) + (b mod n)] mod n

1. [(a mod n)(b mod n)] mod n(ab) mod n

2. [(a mod n)(b mod n)] mod n(ab) mod n

3. [(a mod n) (b mod n)] mod n(a b) mod n

• Modular Arithmetic (contd) Examples for the above three properties

11 mod 83; 15 mod 87

[(11 mod 8)(15 mod 8)] mod 810 mod 82

(1115) mod 826 mod 82

[(11 mod 8)(15 mod 8)] mod 8-4 mod 84

(1115) mod 8-4 mod 84

[(11 mod 8)(15 mod 8)] mod 821 mod 85

(1115)mod 8165 mod 85

• Modular Arithmetic (contd)Properties of modular arithmeticLet Zn = {0,1,2,,(n-1)} be the set of residues modulo n.

Property

Expression

Communicative laws

Associative laws

Distributive law

Identities

(wx) mod n = (xw) mod n

(wx) mod n = (xw) mod n

[(wx)y] mod n = [w(xy)] mod n

[(wx)y] mod n = [w(xy)] mod n

[w(x+y)] mod n = [(wx)+(wy)] mod n

(0w) mod n = w mod n

(1w) mod n = w mod n

For each w(Zn, there exists a z such that wz0 mod n

• Modular Arithmetic (contd)Properties of modular arithmetic (contd)if (a + b) (a + c) mod n, then b c mod n (due to the existence of an additive inverse)if (a b) (a c) mod n, then b c mod n (only if a is relatively prime to n; due to the possible absence of a multiplicative inverse) e.g. 6 3 = 18 2 mod 8 and 6 7 = 42 2 mod 8 but 3 7 mod 8 (6 is not relatively prime to 8)If n is prime then the property of multiplicative inverse holds (from a ring to a field).

• Modular Arithmetic (contd)Properties of modular arithmetic (contd)

Table 7.3 Arithmetic Modulo 7

+ 0 1 2 3 4 5 6

0

0

1

2

3

4

5

6

1

1

2

3

4

5

6

0

2

2

3

4

5

6

0

1

3

3

4

5

6

0

1

2

4

4

5

6

0

1

2

3

5

5

6

0

1

2

3

4

6

6

0

1

2

3

4

5

* 0 1 2 3 4 5 6

0

0

0

0

0

0

0

0

1

0

1

2

3

4

5

6

2

0

2

4

6

1

3

5

3

0

3

6

2

5

1

4

4

0

4

1

5

2

6

3

5

0

5

3

1

6

4

2

6

0

6

5

4

3

2

1

(b)Multiplication modulo7

w

-w

w^-1

0

0

---

1

6

1

2

5

4

3

4

5

4

3

2

5

2

3

6

1

6

(c)Additive and multiplicative inverses modulo 7

• Fermats and Eulers TheoremsFermats theorem

Fermats Theorem

Fermats theorem states the following: If p is prime and a is a positive integer not divisible by p,then

a^(p-1)1 mod p (7.3)

Proof:From our previous discussion, we know that if all the elements of Zp are multiplied by a, modulo p, the result consists of the elements of Zp in some order. Furthermore, a*00 mod p. Therefore, the (p-1) numbers {a mod p, 2a mod p, ,(p-1)a mod p}are just the numbers {1,2,,(p-1)}in some order. Multiply these number together:

a * 2a * * ((p-1)a) [(a mod p) * (2a mod p) * *((p-1)a mod p)]mod p

(p-1)! mod p

But

a * 2a * *((p-1)a) = (p-1)!a^(p-1)

Therefore,

(p-1)!a^(p-1) (p-1)! mod p

We can cancel the (p-1)! term because it is relatively prime to p [see Equation (7.2)]

Recommended