Long modular arithmetic going wrong

77 Views Asked by At

I have attempted to do a question that I crafted by hand: 6239^5 mod 15367

I know that 15367 is made up of prime numbers, notably 121 and 127.

Hence, I break it down by doing 6239^5 mod 121 and 6239^5 mod 127 individually. This yields the following results

6239^5 mod 121 = 109
6239^5 mod 127 = 64

Now I know that x is congruent in the following way:

x ≡ 109 (mod 121)
x ≡ 64 (mod 127)

As such this can then be calculated as:

109 + 121k ≡ 64 (mod 127)
121k (mod 127) ≡ (64-109) (mod 127)
121k (mod 127) ≡ -45 (mod 127)
-6k ≡ -45 (mod 127)
k = 45/6

So we substitute the k into the first formula:
109 + 121k
= 109 + 121(45/6 + 127u)
= 109 + 907.5 + 127u.

I'm stuck now because 907.5 is a decimal.

How do I now work out the final answer?

2

There are 2 best solutions below

1
On

$$-6k\equiv-45\mod 127$$

$$2k\equiv15\equiv142 \mod 127$$

$$k\equiv71\mod 127$$

3
On

One never writes fractions in modular arithmetic. So where you went wrong is on the line $k = 45/6$.

Instead, one computes the multiplicative inverse of $6$ modulo 127. Let's call that number $x$ (you can compute it for yourself or look it up somehow).

Then you would instead have $$-6k \equiv -45 \pmod {127} $$ $$6k \equiv 45 \pmod {127} $$ $$k \equiv 45x \pmod {127} $$ and carry on from there.