[Math] Using Fermat’s Little Theorem or Euler’s Theorem to find the Multiplicative Inverse — Need some help understanding the solutions here.

modular arithmetic

The answers to multiplicative inverses modulo a prime can be found without using the extended Euclidean algorithm.
a. $8^{-1}\bmod17=8^{17-2}\bmod17=8^{15}\bmod17=15\bmod17$
b. $5^{-1}\bmod23=5^{23-2}\bmod23=5^{21}\bmod23=14\bmod23$
c. $60^{-1}\bmod101=60^{101-2}\bmod101=60^{99}\bmod101=32\bmod101$
d. $22^{-1}\bmod211=22^{211-2}\bmod211=22^{209}\bmod211=48\bmod211$

The above is using Fermat's little theorem to find the multiplicative inverse of some modular functions. However, there is a final step just before arriving at the answer that I do not understand how to solve, except to solve it by factoring. Factoring takes a very long time.

Basically, I don't see how the answers move from the third step to the fourth step aside from arriving at the answer by factoring. There has to be a better way using Fermat's Theorem or Euler's Theorem.

Best Answer

The excerpt does not indicate how they compute the power in $\, a^{\large pāˆ’2}\equiv a^{\large āˆ’1}\pmod{\! p}.\,$ One common method is to use powering by repeated squaring. You remark "but this is very time consuming. I am looking for a better way". For manual computations it is often easier to use Gauss's algorithm or other convenient variations of the extended Euclidean algorithm. Here that takes under a minute of purely mental arithmetic as below.

$\bmod 17\!:\ \ \ \ \ \ \dfrac{1}8\equiv \dfrac{2}{16}\equiv \dfrac{2}{-1}\equiv -2 $ $\ \left[\,\rm or\ \ \ \dfrac{1}8\equiv \dfrac{-16}{8},\ \ {\rm or}\,\ \ \dfrac{1}8\equiv \dfrac{18}{-9}\,\right]$

$\bmod 23\!:\ \ \ \ \ \, \dfrac{1}5\equiv \dfrac{5}{25}\equiv \dfrac{5}{2}\equiv\dfrac{28}2\equiv 14 $ $\, \left[\,\rm or\ \ \ \dfrac{1}5\equiv\dfrac{4}{20}\equiv\dfrac{4}{-3}\equiv\dfrac{27}{-3} \right]$

$\bmod 101\!:\,\ \dfrac{1}{60}\equiv \dfrac{2}{120}\equiv \dfrac{2}{19}\equiv\dfrac{10}{95}\equiv\dfrac{10}{-6}\equiv\dfrac{-5}3\equiv\dfrac{96}3\equiv 32$

$\bmod 211\!:\,\ \dfrac{1}{22}\equiv \dfrac{10}{220}\equiv \dfrac{10}{9}\equiv \dfrac{-201}3\:\dfrac{1}3\equiv\dfrac{-67}{3}\equiv\dfrac{144}3\equiv 48$

Beware $\ $ Modular fraction arithmetic is well-defined only for fractions with denominator coprime to the modulus. See here for further discussion.