














































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Prof. Zeph Grunschlag, Computer Science, Number Theory Algorithms, Euclidean Algorithm for GCD, Decimal numbers, Binary numbers, One’s complement, Two’s complement, Arithmetic Algorithms, Columbia, Lecture Notes
Typology: Study notes
1 / 86
This page cannot be seen from the preview
Don't miss anything!















































































Euclidean Algorithm for GCD Number Systems Decimal numbers (base-10) Binary numbers (base-2) One’s complement Two’s complement General base-b number systems Arithmetic Algorithms Addition Multiplication Subtraction 1’s and 2’s complement
33 mod 77 = 33
33 mod 77 = 33
77 mod 33 = 11
33 mod 11 = 0
1 244 mod 117 = 10 117 10 2 117 mod 10 = 7 10 7
1 244 mod 117 = 10 117 10 2 117 mod 10 = 7 10 7 3 10 mod 7 = 3 7 3
gcd(244,117):
By definition 244 and 117 are rel. prime.
1 244 mod 117 = 10 117 10 2 117 mod 10 = 7 10 7 3 10 mod 7 = 3 7 3 4 7 mod 3 = 1 3 1 5 3 mod 1=0 1 0
O (1) + ? ( O (1) + O (1)
Where “?” is the number of while-loop iterations.
- because x ’’ = y ’ = x mod y. Two cases: I. y > ½ x x mod y = x – y < ½ x II. y ≤ ½ x x mod y < y ≤ ½ x
Therefore running time of algorithm is:
operation, so estimate only holds for fixed- size integers such as int’s and long’s)