next up previous
Next: How to Compute Efficiently Up: How to Solve Previous: More About GCDs

To solve $ ax\equiv 1\pmod{n}$

Suppose $ \gcd(a,n)=1$. To solve

$\displaystyle ax\equiv 1\pmod{n},
$

find $ x$ and $ y$ such that $ ax+ny = 1$. Then

$\displaystyle ax \equiv ax + ny \equiv 1 \pmod{n}.
$

Example 1.5   Solve $ 17x \equiv 1\pmod{61}$. First, we use the Euclidean algorithm to find $ x, y$ such that $ 17x+61y=1$:

$\displaystyle \underline{61}$ $\displaystyle =3\cdot\underline{17}+\underline{10}$ so $\displaystyle \underline{10}$ $\displaystyle =\underline{61} - 3\cdot\underline{17}$    
$\displaystyle \underline{17}$ $\displaystyle =1\cdot\underline{10}+\underline{7}$ so $\displaystyle \underline{7}$ $\displaystyle =-\underline{61} + 4\cdot\underline{17}$    
$\displaystyle \underline{10}$ $\displaystyle =1\cdot \underline{7}+\underline{3}$ so $\displaystyle \underline{3}$ $\displaystyle =2\cdot\underline{61} - 7\cdot\underline{17}$    
$\displaystyle \underline{3}$ $\displaystyle =2\cdot\underline{3} +\underline{1}$ so $\displaystyle \underline{1}$ $\displaystyle =-5\cdot\underline{61}+18\cdot\underline{17}$    

Thus $ x=18$ is a solution to $ 17x \equiv 1\pmod{61}$.



William A Stein 2001-09-25