Upload
zane
View
224
Download
0
Embed Size (px)
Citation preview
8/19/2019 Euclidean Algorithm Supplement Number Theory
1/84
Applied Number Theory
Professor Ellen Gethner
February 2, 2016
http://goforward/http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
2/84
Euclidean Algorithm; supplementary material for week 3
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
3/84
Warmup: The Division Algorithm (not really an algorithm)
Division Algorithm. For any a, b ∈ Z+ with a ≥ b , ∃ uniqueintegers q and r such that
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
4/84
Warmup: The Division Algorithm (not really an algorithm)
Division Algorithm. For any a, b ∈ Z+ with a ≥ b , ∃ uniqueintegers q and r such that
a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
5/84
Warmup: The Division Algorithm (not really an algorithm)
Division Algorithm. For any a, b ∈ Z+ with a ≥ b , ∃ uniqueintegers q and r such that
a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
6/84
Warmup: The Division Algorithm (not really an algorithm)
Division Algorithm. For any a, b ∈ Z+ with a ≥ b , ∃ uniqueintegers q and r such that
a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
7/84
Warmup, continued.
A direct and easy-to-prove consequence of the DivisionAlgorithm is the following.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
8/84
Warmup, continued.
A direct and easy-to-prove consequence of the DivisionAlgorithm is the following.
Theorem D. If a, b , c , d , r , s ∈ Z with d = 0 such that d |aand d |b then d |(ra + sb ).
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
9/84
Warmup, continued.
A direct and easy-to-prove consequence of the DivisionAlgorithm is the following.
Theorem D. If a, b , c , d , r , s ∈ Z with d = 0 such that d |aand d |b then d |(ra + sb ).
It then follows that d |(a + b ), d |(a − b ) and d |ra (amongmany other things...).
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
10/84
Warmup, continued.
A direct and easy-to-prove consequence of the DivisionAlgorithm is the following.
Theorem D. If a, b , c , d , r , s ∈ Z with d = 0 such that d |aand d |b then d |(ra + sb ).
It then follows that d |(a + b ), d |(a − b ) and d |ra (amongmany other things...).
In other words, if d divides both a and b , then d divides anyinteger linear combination of a and b . The above are just afew special cases.
http://goforward/http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
11/84
Warmup, greatest common divisor
Definition. Let a, b ∈ Z+. The greatest common divisor of aand b , written gcd (a, b ), is the largest positive integer d that
divides both a and b .
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
12/84
Warmup, greatest common divisor
Definition. Let a, b ∈ Z+. The greatest common divisor of aand b , written gcd (a, b ), is the largest positive integer d that
divides both a and b .
That is, gcd (a, b ) = d .
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
13/84
Warmup, greatest common divisor
Definition. Let a, b ∈ Z+. The greatest common divisor of aand b , written gcd (a, b ), is the largest positive integer d that
divides both a and b .
That is, gcd (a, b ) = d .
Example 1. gcd (4, 6) = 2, gcd (3, 7) = 1, gcd (100, 4) = 4,and gcd (100001, 0) = 100001, etc.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
14/84
Warmup, greatest common divisor
Definition. Let a, b ∈ Z+. The greatest common divisor of aand b , written gcd (a, b ), is the largest positive integer d that
divides both a and b .
That is, gcd (a, b ) = d .
Example 1. gcd (4, 6) = 2, gcd (3, 7) = 1, gcd (100, 4) = 4,and gcd (100001, 0) = 100001, etc.
One place (of many) where gcd is needed is in RSAencryption.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
15/84
Warmup, greatest common divisor
Definition. Let a, b ∈ Z+. The greatest common divisor of aand b , written gcd (a, b ), is the largest positive integer d that
divides both a and b .
That is, gcd (a, b ) = d .
Example 1. gcd (4, 6) = 2, gcd (3, 7) = 1, gcd (100, 4) = 4,and gcd (100001, 0) = 100001, etc.
One place (of many) where gcd is needed is in RSAencryption.
Thus the actual computation of gcd (a, b ) is necessary and
important.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
16/84
Example 2. (Illustration of the Euclidean Algorithm)
Problem. Find gcd (54, 21). That is, compute d = gcd (54, 21)where a = 54 and b = 21.
54 = 2 × 21 + 12 and note that
0 ≤ 12
8/19/2019 Euclidean Algorithm Supplement Number Theory
17/84
Example 2. (Illustration of the Euclidean Algorithm)
Problem. Find gcd (54, 21). That is, compute d = gcd (54, 21)where a = 54 and b = 21.
54 = 2 × 21 + 12 and note that
0 ≤ 12
8/19/2019 Euclidean Algorithm Supplement Number Theory
18/84
Euclidean algorithm example, continued
21 = 1 × 12 + 9 and note that 0 ≤ 9
8/19/2019 Euclidean Algorithm Supplement Number Theory
19/84
Euclidean algorithm example, continued
21 = 1 × 12 + 9 and note that 0 ≤ 9
8/19/2019 Euclidean Algorithm Supplement Number Theory
20/84
Euclidean algorithm example, continued
21 = 1 × 12 + 9 and note that 0 ≤ 9
8/19/2019 Euclidean Algorithm Supplement Number Theory
21/84
Euclidean algorithm example, continued
21 = 1 × 12 + 9 and note that 0 ≤ 9
8/19/2019 Euclidean Algorithm Supplement Number Theory
22/84
Euclidean algorithm example, continued
21 = 1 × 12 + 9 and note that 0 ≤ 9
8/19/2019 Euclidean Algorithm Supplement Number Theory
23/84
Euclidean algorithm example, continued
21 = 1 × 12 + 9 and note that 0 ≤ 9
8/19/2019 Euclidean Algorithm Supplement Number Theory
24/84
The Actual Euclidean Algorithm
Recall that a (mod b ) is the remainder upon dividing a by b . Thatis if a = qb + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
25/84
Euclidean Algorithm Written out in Stages
a = q 1b + r 1 0 ≤ r 1
8/19/2019 Euclidean Algorithm Supplement Number Theory
26/84
Euclidean Algorithm Written out in Stages
a = q 1b + r 1 0 ≤ r 1
8/19/2019 Euclidean Algorithm Supplement Number Theory
27/84
Euclidean Algorithm Written out in Stages
a = q 1b + r 1 0 ≤ r 1
8/19/2019 Euclidean Algorithm Supplement Number Theory
28/84
Euclidean Algorithm Written out in Stages
a = q 1b + r 1 0 ≤ r 1
8/19/2019 Euclidean Algorithm Supplement Number Theory
29/84
Euclidean Algorithm Written out in Stages
a = q 1b + r 1 0 ≤ r 1
8/19/2019 Euclidean Algorithm Supplement Number Theory
30/84
Euclidean Algorithm Written out in Stages
a = q 1b + r 1 0 ≤ r 1
8/19/2019 Euclidean Algorithm Supplement Number Theory
31/84
Euclidean Algorithm Written out in Stages
a = q 1b + r 1 0 ≤ r 1
8/19/2019 Euclidean Algorithm Supplement Number Theory
32/84
Correctness of the Euclidean Algorithm
Does the algorithm halt?
Correctness of the Euclidean Algorithm
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
33/84
g
Does the algorithm halt?
If so, does it produce the desired output, namely gcd (a, b )?
Correctness of the Euclidean Algorithm
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
34/84
g
Does the algorithm halt?
If so, does it produce the desired output, namely gcd (a, b )?
The following lemma will help answer the latter question.
Euclidean Algorithm: A helpful lemma
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
35/84
g p
Lemma. Let a, b ∈ Z+ satisfy a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
36/84
g p
Lemma. Let a, b ∈ Z+ satisfy a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
37/84
Lemma. Let a, b ∈ Z+ satisfy a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
38/84
Lemma. Let a, b ∈ Z+ satisfy a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
39/84
Lemma. Let a, b ∈ Z+ satisfy a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
40/84
Lemma. Let a, b ∈ Z+ satisfy a = bq + r with 0 ≤ r
8/19/2019 Euclidean Algorithm Supplement Number Theory
41/84
Thus it remains to show that d 0|d .
Proof of lemma, continued. So far we have d |d 0
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
42/84
Thus it remains to show that d 0|d .
Here goes. By the definition of gcd we have that d 0|b andthat d 0|(a−
a
b b )
Proof of lemma, continued. So far we have d |d 0
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
43/84
Thus it remains to show that d 0|d .
Here goes. By the definition of gcd we have that d 0|b andthat d 0|(a−
a
b b )
⇒ d |a (by Theorem D)
Proof of lemma, continued. So far we have d |d 0
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
44/84
Thus it remains to show that d 0|d .
Here goes. By the definition of gcd we have that d 0|b andthat d 0|(a−
a
b b )
⇒ d |a (by Theorem D)
⇒ d 0|gcd (a, b )
Proof of lemma, continued. So far we have d |d 0
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
45/84
Thus it remains to show that d 0|d .
Here goes. By the definition of gcd we have that d 0|b andthat d 0|(a−
a
b b )
⇒ d |a (by Theorem D)
⇒ d 0|gcd (a, b )
⇒ d 0|d .
Proof of lemma, continued. So far we have d |d 0
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
46/84
Thus it remains to show that d 0|d .
Here goes. By the definition of gcd we have that d 0|b andthat d 0|(a−
a
b b )
⇒ d |a (by Theorem D)
⇒ d 0|gcd (a, b )
⇒ d 0|d .
In total, we have d |d 0 and d 0|d
Proof of lemma, continued. So far we have d |d 0
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
47/84
Thus it remains to show that d 0|d .
Here goes. By the definition of gcd we have that d 0|b andthat d 0|(a−
a
b b )
⇒ d |a (by Theorem D)
⇒ d 0|gcd (a, b )
⇒ d 0|d .
In total, we have d |d 0 and d 0|d
⇒ d = d 0. That is, gcd (a, b ) = gcd (b , r ). QED
Why is the Euclidean Algorithm Correct?
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
48/84
First, by the lemma, we have r k −1 = gcd (a, b ) because
Why is the Euclidean Algorithm Correct?
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
49/84
First, by the lemma, we have r k −1 = gcd (a, b ) because
gcd (a, b ) = gcd (b , r 1) = gcd (r 1, r 2) = gcd (r 2, r 3) = · · · =gcd (r k −1, r k ) = gcd (r k −1, 0) = r k −1.
Why is the Euclidean Algorithm Correct?
http://goforward/http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
50/84
First, by the lemma, we have r k −1 = gcd (a, b ) because
gcd (a, b ) = gcd (b , r 1) = gcd (r 1, r 2) = gcd (r 2, r 3) = · · · =gcd (r k −1, r k ) = gcd (r k −1, 0) = r k −1.
Finally, and importantly, the algorithm halts becauser 1 > r 2 > r 3 > · · · is a strictly decreasing sequence of non-negative integers, which means that, eventually, r k = 0for some k ≥ 1.
Why is the Euclidean Algorithm Correct?
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
51/84
First, by the lemma, we have r k −1 = gcd (a, b ) because
gcd (a, b ) = gcd (b , r 1) = gcd (r 1, r 2) = gcd (r 2, r 3) = · · · =gcd (r k −1, r k ) = gcd (r k −1, 0) = r k −1.
Finally, and importantly, the algorithm halts becauser 1 > r 2 > r 3 > · · · is a strictly decreasing sequence of non-negative integers, which means that, eventually, r k = 0for some k ≥ 1.
In particular, the last non-zero remainder, namely r k −1, isexactly gcd (a, b ).
Euclidean Algorithm and it’s relation to the FibonacciNumbers
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
52/84
Numbers
Optional Material
Lemma 31.10 in Introduction to Algorithms by Cormen,Lieserson Rivest and Stein: number of recursive calls
http://goforward/http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
53/84
Lieserson, Rivest, and Stein: number of recursive calls
Lemma 31.10 in CLRS If a, b ≥ 1 are integers and
Euclid(a, b ) performs n ≥ 1 recursive calls, then a ≥ F n+2 andb ≥ F n+1, where F i is the i th Fibonacci number.
Lemma 31.10 in Introduction to Algorithms by Cormen,Lieserson Rivest and Stein: number of recursive calls
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
54/84
Lieserson, Rivest, and Stein: number of recursive calls
Lemma 31.10 in CLRS If a, b ≥ 1 are integers and
Euclid(a, b ) performs n ≥ 1 recursive calls, then a ≥ F n+2 andb ≥ F n+1, where F i is the i th Fibonacci number.
Proof by induction on n.
Lemma 31.10 in Introduction to Algorithms by Cormen,Lieserson Rivest and Stein: number of recursive calls
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
55/84
Lieserson, Rivest, and Stein: number of recursive calls
Lemma 31.10 in CLRS If a, b ≥ 1 are integers and
Euclid(a, b ) performs n ≥ 1 recursive calls, then a ≥ F n+2 andb ≥ F n+1, where F i is the i th Fibonacci number.
Proof by induction on n.
The statement P (n) is exactly the statement of the lemma.
Lemma 31.10 in Introduction to Algorithms by Cormen,Lieserson Rivest and Stein: number of recursive calls
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
56/84
Lieserson, Rivest, and Stein: number of recursive calls
Lemma 31.10 in CLRS If a, b ≥ 1 are integers and
Euclid(a, b ) performs n ≥ 1 recursive calls, then a ≥ F n+2 andb ≥ F n+1, where F i is the i th Fibonacci number.
Proof by induction on n.
The statement P (n) is exactly the statement of the lemma.
Base Case. n = 1. Since one recursion occurs we haveb > 0. That is, b ≥ 1 = F 2.
Lemma 31.10 in Introduction to Algorithms by Cormen,Lieserson, Rivest, and Stein: number of recursive calls
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
57/84
Lieserson, Rivest, and Stein: number of recursive calls
Lemma 31.10 in CLRS If a, b ≥ 1 are integers and
Euclid(a, b ) performs n ≥ 1 recursive calls, then a ≥ F n+2 andb ≥ F n+1, where F i is the i th Fibonacci number.
Proof by induction on n.
The statement P (n) is exactly the statement of the lemma.
Base Case. n = 1. Since one recursion occurs we haveb > 0. That is, b ≥ 1 = F 2.
By assumption a > b ⇒ a ≥ 2 = F 3.
Lemma 31.10 in Introduction to Algorithms by Cormen,Lieserson, Rivest, and Stein: number of recursive calls
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
58/84
Lieserson, Rivest, and Stein: number of recursive calls
Lemma 31.10 in CLRS If a, b ≥ 1 are integers and
Euclid(a, b ) performs n ≥ 1 recursive calls, then a ≥ F n+2 andb ≥ F n+1, where F i is the i th Fibonacci number.
Proof by induction on n.
The statement P (n) is exactly the statement of the lemma.
Base Case. n = 1. Since one recursion occurs we haveb > 0. That is, b ≥ 1 = F 2.
By assumption a > b ⇒ a ≥ 2 = F 3.
Also, since b > a (mod b ) (why?) in each recursive callEuclid(â, b̂ ) we have â > b̂ .
Proof of lemma 31.10, continued.
Induction Hypothesis Assume the lemma is true if k 1
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
59/84
Induction Hypothesis. Assume the lemma is true if k − 1recursive calls have made (i.e., assume P (k − 1) is true).
Proof of lemma 31.10, continued.
Induction Hypothesis Assume the lemma is true if k 1
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
60/84
Induction Hypothesis. Assume the lemma is true if k − 1recursive calls have made (i.e., assume P (k − 1) is true).
Inductive Step. We must prove the lemma is true when k recursive calls have been made (i.e., verify P (k ) is true).
Proof of lemma 31.10, continued.
Induction Hypothesis Assume the lemma is true if k − 1
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
61/84
Induction Hypothesis. Assume the lemma is true if k − 1recursive calls have made (i.e., assume P (k − 1) is true).
Inductive Step. We must prove the lemma is true when k recursive calls have been made (i.e., verify P (k ) is true).
To that end, we have k > 0 and b > 0.
Proof of lemma 31.10, continued.
Induction Hypothesis Assume the lemma is true if k − 1
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
62/84
Induction Hypothesis. Assume the lemma is true if k 1recursive calls have made (i.e., assume P (k − 1) is true).
Inductive Step. We must prove the lemma is true when k recursive calls have been made (i.e., verify P (k ) is true).
To that end, we have k > 0 and b > 0.
Assume Euclid(a, b ) makes k recursive calls.
Proof of lemma 31.10, continued.
Induction Hypothesis. Assume the lemma is true if k − 1
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
63/84
Induction Hypothesis. Assume the lemma is true if k 1recursive calls have made (i.e., assume P (k − 1) is true).
Inductive Step. We must prove the lemma is true when k recursive calls have been made (i.e., verify P (k ) is true).
To that end, we have k > 0 and b > 0.
Assume Euclid(a, b ) makes k recursive calls.
Euclid(a, b ) first returns Euclid(b , a (mod b )), which makesk − 1 recursive calls.
Proof of lemma 31.10, continued.
Induction Hypothesis. Assume the lemma is true if k − 1
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
64/84
Induction Hypothesis. Assume the lemma is true if k 1recursive calls have made (i.e., assume P (k − 1) is true).
Inductive Step. We must prove the lemma is true when k recursive calls have been made (i.e., verify P (k ) is true).
To that end, we have k > 0 and b > 0.
Assume Euclid(a, b ) makes k recursive calls.
Euclid(a, b ) first returns Euclid(b , a (mod b )), which makesk − 1 recursive calls.
By the induction hypothesis, we have b ≥ F k +1 and a(mod b ) ≥ F k .
Proof of lemma 31.10, continued.
Induction Hypothesis. Assume the lemma is true if k − 1
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
65/84
duct o ypot es s. ssu e t e e a s t uerecursive calls have made (i.e., assume P (k − 1) is true).
Inductive Step. We must prove the lemma is true when k recursive calls have been made (i.e., verify P (k ) is true).
To that end, we have k > 0 and b > 0.
Assume Euclid(a, b ) makes k recursive calls.
Euclid(a, b ) first returns Euclid(b , a (mod b )), which makesk − 1 recursive calls.
By the induction hypothesis, we have b ≥ F k +1 and a(mod b ) ≥ F k .
It remains to show that a ≥ F k +2.
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
66/84
Note that b + a (mod b )
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
67/84
Note that b + a (mod b )
= b + r
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
68/84
Note that b + a (mod b )
= b + r
= b + (a−
a
b b )
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
69/84
Note that b + a (mod b )
= b + r
= b + (a−
a
b b )
≤ a
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
70/84
Note that b + a (mod b )
= b + r
= b + (a−
a
b b )
≤ a
because ab > 1.
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
71/84
Thus we have that a ≥ b + a (mod b )
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
72/84
Thus we have that a ≥ b + a (mod b )
≥ F k +1 + F k
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
73/84
Thus we have that a ≥ b + a (mod b )
≥ F k +1 + F k
= F k +2, as desired.
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
74/84
Thus we have that a ≥ b + a (mod b )
≥ F k +1 + F k
= F k +2, as desired.
Conclusion. If Euclid(a, b ) makes n recursive calls thena ≥ F n+2 and b ≥ F n+1.
Proof of lemma 31.10, continued. Must show a ≥ F k +2.
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
75/84
Thus we have that a ≥ b + a (mod b )
≥ F k +1 + F k
= F k +2, as desired.
Conclusion. If Euclid(a, b ) makes n recursive calls thena ≥ F n+2 and b ≥ F n+1.
QED
Direct Consequence of Lemma 31.10
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
76/84
Theorem 31.11. If a > b ≥ 1 and b
8/19/2019 Euclidean Algorithm Supplement Number Theory
77/84
Theorem 31.11. If a > b ≥ 1 and b
8/19/2019 Euclidean Algorithm Supplement Number Theory
78/84
Theorem 31.11. If a > b ≥ 1 and b
8/19/2019 Euclidean Algorithm Supplement Number Theory
79/84
Recall that a = F n+2 and b = F n+1 .
Best possible theorem
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
80/84
Recall that a = F n+2 and b = F n+1 .
Then gcd (F n+1,F n) = gcd (F n,F n−1) = · · · = gcd (F 1, F 0) =gcd (1, 0) = 1.
Best possible theorem
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
81/84
Recall that a = F n+2 and b = F n+1 .
Then gcd (F n+1,F n) = gcd (F n,F n−1) = · · · = gcd (F 1, F 0) =gcd (1, 0) = 1.
Thus n recursive calls will be made ⇒ the theorem is best
possible.
Best possible theorem
R ll h F d b F
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
82/84
Recall that a = F n+2 and b = F n+1 .
Then gcd (F n+1,F n) = gcd (F n,F n−1) = · · · = gcd (F 1, F 0) =gcd (1, 0) = 1.
Thus n recursive calls will be made ⇒ the theorem is best
possible.
Finally, given that F n ≈ φn
5 , where φ = 1+
√ 5
2 , we see that
Best possible theorem
R ll h F d b F
http://find/
8/19/2019 Euclidean Algorithm Supplement Number Theory
83/84
Recall that a = F n+2 and b = F n+1 .
Then gcd (F n+1,F n) = gcd (F n,F n−1) = · · · = gcd (F 1, F 0) =gcd (1, 0) = 1.
Thus n recursive calls will be made ⇒ the theorem is best
possible.
Finally, given that F n ≈ φn
5 , where φ = 1+
√ 5
2 , we see that
Euclid(a, b ) makes C log b recursive calls.
Best possible theorem
R ll th t F d b F
http://goforward/http://find/http://goback/
8/19/2019 Euclidean Algorithm Supplement Number Theory
84/84
Recall that a = F n+2 and b = F n+1 .
Then gcd (F n+1,F n) = gcd (F n,F n−1) = · · · = gcd (F 1, F 0) =gcd (1, 0) = 1.
Thus n recursive calls will be made ⇒ the theorem is best
possible.
Finally, given that F n ≈ φn
5 , where φ = 1+
√ 5
2 , we see that
Euclid(a, b ) makes C log b recursive calls.
Moral of the story: recursion is not always bad!
http://goforward/http://find/http://goback/