gf(2) Calculating the gcd (greatest common divisor)

Euclid's Algorithm

c = gcd(a0,b0)

a0 = b0000000000000000000000000000000000000000000001101010101111101101
a0 = 0x000000000006abed
a0 = x18 + x17 + x15 + x13 + x11 + x9 + x8 + x7 + x6 + x5 + x3 + x2 + 1

b0 = b0000000000000000000000000000000000000000000000011100010001011110
b0 = 0x000000000001c45e
b0 = x16 + x15 + x14 + x10 + x6 + x4 + x3 + x2 + x

Find r0 = a0 % b0

r0 = b0000000000000000000000000000000000000000000000000111111011001011
r0 = 0x0000000000007ecb
r0 = x14 + x13 + x12 + x11 + x10 + x9 + x7 + x6 + x3 + x + 1

r0 is not zero nor one, so continue...

a1 = b0
a1 = b0000000000000000000000000000000000000000000000011100010001011110
a1 = 0x000000000001c45e
a1 = x16 + x15 + x14 + x10 + x6 + x4 + x3 + x2 + x

b1 = r0
b1 = b0000000000000000000000000000000000000000000000000111111011001011
b1 = 0x0000000000007ecb
b1 = x14 + x13 + x12 + x11 + x10 + x9 + x7 + x6 + x3 + x + 1

Find r1 = a1 % b1

r1 = b0000000000000000000000000000000000000000000000000011111101110010
r1 = 0x0000000000003f72
r1 = x13 + x12 + x11 + x10 + x9 + x8 + x6 + x5 + x4 + x

r1 is not zero nor one, so continue...

a2 = b1
a2 = b0000000000000000000000000000000000000000000000000111111011001011
a2 = 0x0000000000007ecb
a2 = x14 + x13 + x12 + x11 + x10 + x9 + x7 + x6 + x3 + x + 1

b2 = r1
b2 = b0000000000000000000000000000000000000000000000000011111101110010
b2 = 0x0000000000003f72
b2 = x13 + x12 + x11 + x10 + x9 + x8 + x6 + x5 + x4 + x

Find r2 = a2 % b2

r2 = b0000000000000000000000000000000000000000000000000000000000101111
r2 = 0x000000000000002f
r2 = x5 + x3 + x2 + x + 1

r2 is not zero nor one, so continue...

a3 = b2
a3 = b0000000000000000000000000000000000000000000000000011111101110010
a3 = 0x0000000000003f72
a3 = x13 + x12 + x11 + x10 + x9 + x8 + x6 + x5 + x4 + x

b3 = r2
b3 = b0000000000000000000000000000000000000000000000000000000000101111
b3 = 0x000000000000002f
b3 = x5 + x3 + x2 + x + 1

Find r3 = a3 % b3

r3 = b0000000000000000000000000000000000000000000000000000000000000000
r3 = 0x0000000000000000
r3 = 0

r3 is zero, so c=gcd(a,b)=b3

c = b0000000000000000000000000000000000000000000000000000000000101111
c = 0x000000000000002f
c = x5 + x3 + x2 + x + 1


See also: