xm-number

xm-number - Algorithms Non-Lecture M: Number-Theoretic...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Algorithms Non-Lecture M: Number-Theoretic Algorithms And its one, two, three, What are we fighting for? Dont tell me, I dont give a damn, Next stop is Vietnam; [or: This time well kill Saddam] And its five, six, seven, Open up the pearly gates, Well there aint no time to wonder why, Whoopee! Were all going to die. Country Joe and the Fish I-Feel-Like-Im-Fixin-to-Die Rag" (1967) There are 0 kinds of mathematicians: Those who can count modulo 2 and those who cant. Anonymous God created the integers; all the rest is the work of man. Kronecker M Number Theoretic Algorithms M.1 Greatest Common Divisors Before we get to any actual algorithms, we need some definitions and preliminary results. Unless specifically indicated otherwise, all variables in this lecture are integers. The symbol ZZ (from the German word Zahlen", meaning numbers or to count) to denote the set of integers. We say that one integer d divides another integer n , or that d is a divisor of n , if the quotient n / d is also an integer. Symbolically, we can write this definition as follows: d | n n d = n d In particular, zero is not a divisor of any integer is not an integerbut every other integer is a divisor of zero. If d and n are positive, then d | n immediately implies that d n . Any integer n can be written in the form n = qd + r for some non-negative integer 0 r | d- 1 | . Moreover, the choices for the quotient q and remainder r are unique: q = n d and r = n mod d = n- d n d . Note that the remainder n mod d is always non-negative, even if n < 0 or d < 0 or both. 1 If d divides two integers m and n , we say that d is a common divisor of m and n . Its trivial to prove (by definition crunching) that any common divisor of m and n also divides any integer linear combination of m and n : ( d | m ) and ( d | n ) = d | ( am + bn ) The greatest common divisor of m and n , written gcd ( m , n ) , 2 is the largest integer that divides both m and n . Sometimes this is also called the greater common denominator . The greatest common divisor has another useful characterization as the smallest element of another set. Lemma 1. gcd ( m , n ) is the smallest positive integer of the form am + bn . 1 The sign rules for the C / C ++ / Java % operator are just plain stupid. I cant count the number of times Ive had to write x = (x+n)%n; instead of x %= n; . Frickin idiots . Gah! 2 Do not use the notation ( m , n ) for greatest common divisor, unless you want Notation Kitty to visit you in the middle of the night and remove your eyes while you sleep. Nice kitty. 1 Algorithms Non-Lecture M: Number-Theoretic Algorithms Proof: Let s be the smallest positive integer of the form am + bn . Any common divisor of m and n is also a divisor of s = am + bn . In particular, gcd ( m , n ) is a divisor of s , which implies that gcd ( m , n ) s ....
View Full Document

Page1 / 9

xm-number - Algorithms Non-Lecture M: Number-Theoretic...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online