Professional Documents
Culture Documents
5
5
5
x in the equation
(
11111
⋅
)
m
o
d
12345
=
1
(11111⋅x)mod12345=1, you can use modular arithmetic. The equation can be written
as:
11111
≡
1
(
m
o
d
12345
)
11111x≡1(mod12345)
To find the modular inverse, you can use the extended Euclidean algorithm. The
algorithm will find two integers
a and
b such that
11111
+
12345
=
gcd
(
11111
,
12345
)
11111a+12345b=gcd(11111,12345). If
gcd
(
11111
,
12345
)
=
1
gcd(11111,12345)=1, then
Initialize:
=
11111
a=11111,
=
12345
b=12345
Set
1
=
0
,
1
=
1
,
2
=
1
,
2
=
0
x
1
=0,y
1
=1,x
2
=1,y
2
=0
Iteration:
Until
≠
0
b
=0:
=
⌊
⌋
q=⌊a/b⌋
Update
a,b as
m
o
d
a=b,b=amodb
Update
1
,
2
x
1
,x
2
as
1
=
2
,
2
=
1
−
2
x
1
=x
2
,x
2
=x
1
−qx
2
Update
1
,
2
y
1
,y
2
as
1
=
2
,
2
=
1
−
2
y
1
=y
2
,y
2
=y
1
−qy
2
Result:
If
gcd
(
11111
,
12345
)
=
1
gcd(11111,12345)=1, then the
1
x
1
Iteration 1:
=
0
q=0,
=
11111
a=11111,
=
12345
b=12345
1
=
1
x
1
=1,
2
=
0
x
2
=0,
1
=
0
y
1
=0,
2
=
1
y
2
=1
Iteration 2:
=
0
q=0,
=
12345
a=12345,
=
11111
b=11111
1
=
0
x
1
=0,
2
=
1
x
2
=1,
1
=
1
y
1
=1,
2
=
0
y
2
=0
Now,
gcd
(
11111
,
12345
)
=
1
gcd(11111,12345)=1, and the
1
x
1
So,
=
1
x=1 is the solution to the equation
(
11111
⋅
)
m
o
d
12345
=
1
(11111⋅x)mod12345=1.