xโกa1modn1xโกa2modn2โฏxโกakmodnk
N=โi=1kni
Where the ni are pairwise coprime. then there is one and only one integer x,0โคx<N satisfy them.
xโกa1modn1xโกa2modn2
n1m1+n2m2=1 calculate m1,m2 by Extended Euclidean algorithm
x=a1n2m2+a2n1m1=a1(1โn1m1)+a2n1m1=a1n2m2+a2(1โn2m2)=a1+(a2โa1)m1n1=a2+(a1โa2)n2m2
example
xโก2mod3xโก3mod5xโก2mod7
calculate:
3m1+5m2=1
r0=a=5s0=1t0=0r1=b=3s1=0t1=1r2=r0โq1r1=5โ1โ 3=2s2=s0โq1s1=1โ1โ 0=1t2=t0โq1t1=0โ1โ 1=โ1r3=r1โq2r2=3โ1โ 2=1s3=s1โq2s2=0โ1โ 1=โ1t3=t1โq2t2=1โ1โ (โ1)=2r4=r2โq3r3=2โ2โ 1=0s4=s2โq3s3=1โ2โ (โ1)=3t4=t2โq3t3=โ1โ2โ 2=โ5
gcd(5,3)=1 m1=s3=2 m2=t3=โ1 3โ 2+5โ (โ1)=1
x1,2=a1n2m2+a2n1m1=2โ 5โ (โ1)+3โ 3โ 2=8
xโก8mod15xโก2mod7
calculate: 15m1+7m2=1
r0=a=15s0=1t0=0r1=b=7s1=0t1=1r2=r0โq1r1=15โ2โ 7=1s2=s0โq1s1=1โ2โ 0=1t2=t0โq1t1=0โ2โ 1=โ2r3=r1โq2r2=7โ7โ 1=0s3=s1โq2s2=0โ7โ 1=โ7t3=t1โq2t2=1โ7โ (โ2)=15
gcd(15,7)=1 m1=s3=1 m2=t3=โ2 x=8โ 7โ (โ2)+2โ 15โ 1=โ112+30=โ82
xโกโ82โก=โ82+15โ 7=23mod105
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up