x≡5mod15x≡8mod21
The extended Euclidean algorithm gives x≡50mod105.
I understand now that if we combine the two it implies 15a−21b=3 but I don't understand how to use the extended GCD to go from there to finding x and the corresponding modulus.
This is what I am using for the extended gcd computations:
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (b // a) * y, y)
Answer
Since the GCD of the moduli is (15,21)=3, it is necessary that x be the same thing in both equations mod 3. That is,
x≡5(mod15)⟹x≡2(mod3)
and
x≡8(mod21)⟹x≡2(mod3)
If we didn't get that x≡2(mod3) from both equations, a solution would not be possible.
This prompts us to look at x−23(mod153) and x−23(mod213). That is,
x−23≡1(mod5)
and
x−23≡2(mod7)
Using the Extended Euclidean Algorithm as implemented in this answer,
122101−2501−13−775210
we get that
5(3)⏟15+7(−2)⏟−14=1
We can use (4) to see that
−14≡1(mod5)−14≡0(mod7)
and that
15≡0(mod5)15≡1(mod7)
To solve (1) and (2) we can add 1 times (5) to 2 times (6) to get
16≡1(mod5)16≡2(mod7)
Equations (7) tell us that x−23≡16(mod35) or that
\bbox[5px,border:2px solid #C0A000]{x\equiv50\pmod{105}}\tag{8}
No comments:
Post a Comment