Euclid's Algorithm Flashcards
Computes gcd of a and b
1
Q
Compute the gcd of 90 and 24
A
Divide previous two and keep remainder
90/24 remainder is 18
24 /18 remainder = 6
18/ 6 remainder = 0
gcd is 6
2
Q
Why is euclid memory efficient?
A
Only store maximum three balues at once
3
Q
Extended Euclid: output
A
gcd(a,b), u, v such that gcd(a,b) = au + bv
4
Q
Extended Euclid: Compute 90 and 24.
A
gcd(90,24) = 90u + 24v
90 = 243 + 18
24 = 181 + 6
18 = 6*3+0
18 = 90-243
6 = 24-181
6 = 24-(90-243)1
6 = -90+24*4
so u = -1 and v = 4