1

This summer I am taking a cryptology class and a common task we need to do is finding the modular inverse. When finding the modular inverse for the following I would do it like so:

  1. 12 mod 23
  2. 23 mod 101

I just start at 1 and count by the modulo until I find a number that is divisible by the first number. how I do it

This strategy works well when the numbers are small but sometimes it takes forever. Is there a better way I should be doing this? If so can you play do so using these examples given? Thanks and have a great day.

  • 2
    If you want to find $a^{-1}$ modulo $b$, then you can find $p$ and $q$ such that $ap+bq=1$ via Euclid's algorithm. – richrow Jul 07 '21 at 05:21
  • The best way is probably to follow Dubuque's algorithm https://math.stackexchange.com/questions/174676/solving-linear-congruences-by-hand-modular-fractions-and-inverses/174687#174687 – Evariste Jul 07 '21 at 22:30

1 Answers1

1

Essentially, you are solving

  1. $12x\equiv1\pmod{23};$
  2. $23x\equiv1\pmod{101},$

which is equivalent to obtaining the $x$-solutions of the Diophantine equations (polynomials of which only integer solutions are of interest)

  1. $12x+23y=1;$
  2. $23x+101y=1.$

Alternative Procedure A:

  1. Working $\mod23:$ $$12x\equiv1\\(12-23)x\equiv1-23\\-11x\equiv-22\\x\equiv2;$$

  2. Working $\mod101:$ $$23x\equiv1\\23x\equiv1+5\times101\\23x\equiv506\\x\equiv22.$$


Alternative Procedure B:

  1. Euclidean algorithm: $$23=1(12)+11\\12=1(11)+1\\$$ Reversing the above equations: $$1=12-1(11)\\=12-(23-1(12))\\=2(12)-23$$ In $\mathbb Z_{23},$ $$1=2(12)\\12^{-1}=2;$$

  2. Euclidean algorithm: $$101=4(23)+9\\23=2(9)+5\\9=1(5)+4\\5=1(4)+1$$ Reversing the above equations: $$1=5-1(4)\\=5-(9-1(5))\\=2(5)-9\\=2(23-2(9))-9\\=2(23)-5(9)\\=2(23)-5(101-4(23))\\=22(23)-5(101)$$ In $\mathbb Z_{101},$ $$1=22(23)\\23^{-1}=22.$$

ryang
  • 38,879
  • 14
  • 81
  • 179