X = 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
Y = 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
X ↔ Y

Ext-GCD(5, 8) :

i GCD Bezout AOdd : AEven :
A B ax ay bx by |A-B| A↔B Sx Sy ax
Sx'
ay
Sy'
A
A/2
ax
ax + Y
ay
ay + X
ax
ax/2
ay
ay/2
0 5 8 1 0 0 1
1 8 5 0 1 1 0 3 4 8 6 4 3
2 4 5 4 3 1 0 1 2 12 8 6 4
3 2 5 6 4 1 0 3 1 Even Even 3 2
4 1 5 3 2 1 0 4 1 4 2 4 2 2 Even Even 2 1
5 2 1 2 1 3 2 1 1 10 6 5 3
6 1 1 5 3 3 2 0
7 1 1 5 3 3 2 0
(5)(5) - (3)(8) = 1