Theorem 3.5
Let
a
,
b
,
r
0
, r
1
, . . . , r
‘
+1
, and
q
1
, . . . , q
‘
be as in Theorem 3.3.
Define integers
s
0
, s
1
, . . . , s
‘
+1
and
t
0
, t
1
, . . . , t
‘
+1
as follows:
s
0
:= 1
,
t
0
:= 0
,
s
1
:= 0
,
t
1
:= 1
,
and for
1
≤
i
≤
‘
,
s
i
+1
:=
s
i

1

s
i
q
i
,
t
i
+1
:=
t
i

1

t
i
q
i
.
Then
(i) for
0
≤
i
≤
‘
+ 1
, we have
s
i
a
+
t
i
b
=
r
i
; in particular,
s
‘
a
+
t
‘
b
= gcd(
a, b
)
;
(ii) for
0
≤
i
≤
‘
, we have
s
i
t
i
+1

t
i
s
i
+1
= (

1)
i
;
(iii) for
0
≤
i
≤
‘
+ 1
, we have
gcd(
s
i
, t
i
) = 1
;
(iv) we have

s
‘
+1
 ≤
b
and

t
‘
+1
 ≤
a
;
(v) for
0
≤
i
≤
‘
, we have

t
i
 ≤ 
t
i
+1

, and for
1
≤
i
≤
‘
, we have

s
i
 ≤ 
s
i
+1

;
(vi) for
0
≤
i
≤
‘
+ 1
, we have

s
i
 ≤
b
and

t
i
 ≤
a
.
Proof.
(i) and (ii) are easily proved by induction on
i
(exercise).
(iii) follows directly from (ii).
To prove (iv), note that
s
‘
+1
a
+
t
‘
+1
b
=
r
‘
+1
= 0.
We have
t
‘
+1
6
= 0, since otherwise, both
s
‘
+1
and
t
‘
+1
would be zero, contradicting (ii). This implies that
t
‘
+1
/s
‘
+1
=

a/b
, and then (iv)
follows from the fact (iii) that gcd(
s
‘
+1
, t
‘
+1
) = 1.
For (v), one proves the statement for the
t
i
by induction, but with the stronger hypothesis that
t
i
t
i
+1
≤
0 (i.e., the sign alternates) and

t
i
 ≤ 
t
i
+1

for 0
≤
i
≤
‘
(exercise). One argues similarly
for the statement for the
s
i
.
(vi) follows immediately from (iv) and (v).
2
Example 3.2
We continue with Example 3.1. The numbers
s
i
and
t
i
are easily computed from
the
q
i
:
i
0
1
2
3
4
r
i
100
35
30
5
0
q
i
2
1
6
s
i
1
0
1
1
7
t
i
0
1
2
3
20
2
We can easily turn the scheme described in Theorem 3.5 into a simple algorithm, as follows:
s
←
1
, t
←
0
s
0
←
0
, t
0
←
1
while
b
6
= 0 do
Compute
q, r
such that
a
=
bq
+
r
, with 0
≤
r < b
(
s, t, s
0
, t
0
)
←
(
s
0
, t
0
, s

s
0
q, t

t
0
q
)
(
a, b
)
←
(
b, r
)
output
a, s, t
16