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 = b0000000000000000000000000000000000000000000000100110101110101010
b0 = 0x0000000000026baa
b0 = x17 + x14 + x13 + x11 + x9 + x8 + x7 + x5 + x3 + x

Find r0 = a0 % b0

r0 = b0000000000000000000000000000000000000000000000000001011100010011
r0 = 0x0000000000001713
r0 = x12 + x10 + x9 + x8 + x4 + x + 1

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

a1 = b0
a1 = b0000000000000000000000000000000000000000000000100110101110101010
a1 = 0x0000000000026baa
a1 = x17 + x14 + x13 + x11 + x9 + x8 + x7 + x5 + x3 + x

b1 = r0
b1 = b0000000000000000000000000000000000000000000000000001011100010011
b1 = 0x0000000000001713
b1 = x12 + x10 + x9 + x8 + x4 + x + 1

Find r1 = a1 % b1

r1 = b0000000000000000000000000000000000000000000000000000100001100111
r1 = 0x0000000000000867
r1 = x11 + x6 + x5 + x2 + x + 1

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

a2 = b1
a2 = b0000000000000000000000000000000000000000000000000001011100010011
a2 = 0x0000000000001713
a2 = x12 + x10 + x9 + x8 + x4 + x + 1

b2 = r1
b2 = b0000000000000000000000000000000000000000000000000000100001100111
b2 = 0x0000000000000867
b2 = x11 + x6 + x5 + x2 + x + 1

Find r2 = a2 % b2

r2 = b0000000000000000000000000000000000000000000000000000011111011101
r2 = 0x00000000000007dd
r2 = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

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

a3 = b2
a3 = b0000000000000000000000000000000000000000000000000000100001100111
a3 = 0x0000000000000867
a3 = x11 + x6 + x5 + x2 + x + 1

b3 = r2
b3 = b0000000000000000000000000000000000000000000000000000011111011101
b3 = 0x00000000000007dd
b3 = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

Find r3 = a3 % b3

r3 = b0000000000000000000000000000000000000000000000000000000000000000
r3 = 0x0000000000000000
r3 = 0

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

c = b0000000000000000000000000000000000000000000000000000011111011101
c = 0x00000000000007dd
c = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1


See also: