Docsity

Division Algorithm - Discrete Mathematics - Lecture Slides, Slides of Discrete Mathematics

Partial preview of the text

Download Division Algorithm - Discrete Mathematics - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

CSci 2011

Discrete Mathematics

Lecture 14

Division Algorithm

Theorem: Let a be an integer and d a

positive integer. Then there exist unique q

and r, with 0≤q<r, such that a = dq + r.

Definition

q = a div d, quotient r = a mod d, remainder

Modular Arithmetic

Theorem: Let m be a positive integer.

a ≡ b mod m iff ∃ k such that a = b + km.

More…

Theorem: Let m be a positive integer. If a ≡

b mod m and c ≡ d mod m, then

a + c ≡ b + d mod m. ac ≡ bd mod m.

Caesar Cipher

Alphabet to number: a~0, b~1, … , z~1.

Encryption: EK(x) = x + K mod 26.

Decryption:

Caesar used K = 3.

If you don’t know K and you have a secret

text, would you be able to find K? How?

Showing a number is prime

Show that 113 is prime

Solution

The only prime factors less than √113 = 10. are 2, 3, 5, and 7 Neither of these divide 113 evenly Thus, by the fundamental theorem of arithmetic, 113 must be prime

The prime number theorem

The radio of the number of primes not exceeding

x and x /ln( x ) approaches 1 as x grows without

bound

Rephrased: the number of prime numbers less than x is approximately x /ln( x )

When x = 2^512 , # of primes = 2^512 /512 ∼ 2503

Greatest common divisor

The greatest common divisor of two integers

a and b is the largest integer d such that

d | a and d | b

Denoted by gcd(a,b)

Examples

gcd (24, 36) = 12 gcd (17, 22) = 1 gcd (100, 17) = 1

Pairwise relative prime

A set of integers a 1 , a 2 , … an are pairwise relatively prime if, for all pairs of numbers, they are relatively prime  Formally: The integers a 1 , a 2 , … an are pairwise relatively prime if gcd( ai, aj ) = 1 whenever 1 ≤ i < j ≤ n.

Example: are 10, 17, and 21 pairwise relatively prime?  gcd(10,17) = 1, gcd (17, 21) = 1, and gcd (21, 10) = 1  Thus, they are pairwise relatively prime

Example: are 10, 19, and 24 pairwise relatively prime?  Since gcd(10,24) ≠ 1, they are not

More on gcd’s

Given two numbers a and b , rewrite them

as:

Example: gcd (120, 500) 120 = 2^3 35 = 2^3 *3^1 *5^1 500 = 2^2 *5^3 = 2^2 *3^0 *5^3

Then compute the gcd by the following

formula:

Example: gcd(120,500) = 2min(3,2) 3 min(1,0) 5 min(1,3) = 2^2 30 51 = 20

n b n n

a b b n a pa^^1 pa^2 ... p , b p^1 p^2 ... p = 1 2 = 1 2

min( , ) min( , ) 2

min( , ) gcd( , ) 1 ... 1 1 2 2 an bn n a b = p a^ b p a b p

lcm and gcd theorem

Let a and b be positive integers. Then a*b = gcd( a , b ) * lcm ( a , b )

Example: gcd (10,25) = 5, lcm (10,25) = 50  1025 = 5

Example: gcd (95256, 432) = 216, lcm (95256,

  1. = 190512  95256432 = 216

Example Proof

Prove or disprove that n 2 - 79n + 1601 is

prime, whenever n is a positive integer.

(Disprove)

When n = 1601,

n^2 - 79n + 1601 = 1601 (1601 - 79 + 1)

Prove or disprove that p_1p_2…p_n+1 is a

prime, whenever n is a positive integer.

Eucledean Algorithm

Let a = b q + r, where a, b, q, r be integers.

Then gcd (a, b) = gcd (b, r).

Proof on book is not enough!

Eucledian Algorithm

procedure gcd (a, b: positive integer)

x := a, y := b while y ≠ 0 r := x mod y x := y y := r Return r