Find the inverse of 17 mod 41 Questions
(1) Find the inverse of $17 \mod 41$.
(2) Find the smallest positive number n so that $17n \equiv 14 \pmod{41}$

For the first question, my attempt is as follows:
$$41-17\cdot2=7$$
$$17-7\cdot2=3$$
$$7-3\cdot2=1$$
$$7-2(17-7\cdot2)=1$$
$$7-2\cdot17=1$$
$$41-17\cdot2-2\cdot17=1$$
$$41-4\cdot17=1$$
So the inverse of $17$ is $-4$.
That is, the inverse of $17$ is $37$
Am I right?
 A: Modular inverses can be rotely computed by the extended Euclidean algorithm, as well as other less-known methods methods that are sometimes simpler for small numbers. A few are below.
Fiirst we consider Gauss's algorithm, which scales the (top & bottom) of the fraction to make the bottom smaller when reduced mod $41$, e.g. $\,2\cdot 17\equiv -7\,$ below (all congruences are mod $41)$

Gauss's algorithm: $\,\  \color{#0a0}{\dfrac{1}{17}}\equiv \dfrac{2}{34}\equiv \dfrac{2}{-7}\equiv \dfrac{-12}{42}\equiv \dfrac{\color{#c00}{-12}}1$

Ext. Euclid in fractions: $\,\  \dfrac{1}{17}\equiv \dfrac{-2}{7}\equiv \dfrac{5}3\equiv\dfrac{\color{#c00}{-12}}1$

Factoring: $\,\ \color{#0a0}{\color{#0a0}{\dfrac{1}{17}}}\equiv \dfrac{42}{17}\equiv 6\cdot \dfrac{7}{17}\equiv 6\cdot\dfrac{-34}{17}\equiv 6(-2)\equiv\color{#c00}{-12}$

Therefore $\ 17x \equiv 14\,\Rightarrow\, x\equiv (\color{#0a0}{1/17})14 \equiv(\color{#c00}{-12})14\equiv -4(3\cdot 14)\equiv -4$

Alternatively we can compute $\,14/17\,$ directly using factoring as above
namely $\,\ {\rm mod}\ 41\!:\,\ \dfrac{14}{17}\equiv 2\cdot \dfrac{7}{17}\equiv 2\cdot\dfrac{-34}{17}\equiv 2(-2)\equiv -4$

Beware $ $ Modular fraction arithmetic is valid only for fractions with denominator coprime to the modulus. See here for further discussion.  
A: Under the Extended Euclidean algorithm, you annotate the process of finding a GCD with how you got there. This can be used for finding multiplicative inverses:
$$
\begin{array}{c|c|c|c|l}
q & r & a & b & \text{implied equation} \\ \hline
 & 41 & 1 & 0 & 41 = 1\cdot 41 + 0\cdot 17\\
 & 17 & 0 & 1 & 17 = 0\cdot 41 + 1\cdot 17\\
2 & 7 & 1 & -2 & \;\; 7 = 1\cdot 41 + (-2)\cdot 17\\
2 & 3 & -2 & 5 & \;\;3 = (-2)\cdot 41 + 5\cdot 17\\
2 & 1 & 5 & \color{red}{-12} & \;\;1 = 5\cdot 41 + (-12)\cdot 17\\
\end{array}
$$
The first two lines setup the numbers under consideration as the bases. Then at each stage, $q$ gives the integer division result for the preceding two $r$ values, which then determines how to construct the $r$, $a$ and $b$ values for the  current row: subtract off $q$ times the row above value from the row above that. (The final column here is not needed, it's just to aid understanding if you haven't seen this before).
This gives us the relevant Bezout's identity, $5\cdot 41 + (-12)\cdot 17 = 1 $, which immediately gives us $-12$ as the inverse of $17 \bmod 41$:
$5\cdot 41 + (-12)\cdot 17 \equiv (-12)\cdot 17 \equiv 29\cdot 17 \equiv 1 \bmod 41$
that is, $17^{-1} \equiv 29 \bmod 41$ .
The second question is then easily solved since $17n\equiv 14 \bmod 41$ $\implies$ $n\equiv -12\cdot 14 \bmod 41$  (i.e. $n\equiv -168 \equiv -4 \equiv 37 \bmod 41$ ).
A: \begin{align*}
    41 &= 2 \cdot 17 + 7  &  7 &= 1 \cdot 41 - 2 \cdot 17  \\
    17 &= 2 \cdot 7 + 3   &  3 &= 1 \cdot 17 - 2 \cdot (1 \cdot 41 - 2 \cdot 17)  \\
                         &&    &= 5 \cdot 17 - 2 \cdot 41  \\
     7 &= 2 \cdot 3 + 1   &  1 &= 1 \cdot 7 - 2 \cdot 3  \\
                         &&    &= 1\cdot(1 \cdot 41 - 2 \cdot 17) - 2 \cdot (5 \cdot 17 - 2 \cdot 41)  \\
                         &&    &= 5 \cdot 41 - 12 \cdot 17
\end{align*}
Therefore $17^{-1} \cong -12 \cong 29 \pmod{41}$.
A: The mistake I spotted in your answer is here:.
After arriving at  $7-2(17-7*2)=1$ you simplified it wrongly as $7-2*17=1$, correct simplification is $5*7-2*17=1$. Then proceed.
A: $$17x\equiv 1\pmod{41}\\-24x\equiv -40\pmod{41}\\3x\equiv 5\pmod{41}\\3x\equiv-36\pmod{41}\\x\equiv -12\equiv29\pmod{41}$$
Multiplying $x\equiv29\pmod{41}$ by $14$ also gives a correct solution though I'm not quite sure if it's a coincidence or not.$$\\17x\equiv14\pmod{41}\\-24x\equiv14\pmod{41}\\-12x\equiv 7\pmod{41}\\-12x\equiv-34\pmod{41}\\6x\equiv17\pmod{41}\\6x\equiv-24\pmod{41}\\x\equiv -4\equiv37\pmod{41}$$
A: For the first Q.
Let $17=x_1.$ For each $n,$ if $|x_n|>1,$ take positive integer $K_n$ such that $$|K_nx_n|<41<|(1+K_n)x_n| .$$ Take $x_{n+1}$ with $41>|x_{n+1}|$ where: ...
(i). If $41-|K_nx_n|<|(1+K_n)x_n|-41$ then $x_{n+1}\equiv K_nx_n \pmod {41}$...
(ii). Otherwise $x_{n+1}\equiv (1+K_n)x_n \pmod {41}.$ 
(This is faster than simply taking $x_{n+1}\equiv 41- K_nx_n \pmod {41},$ as it ensures that if $|x_n|>1$ then $|x_{n+1}|\leq |x_n|/2.)$ 
If $|x_n|=1$ then stop. 
We have $17=x_1$ and $34=17\cdot 2<41<17\cdot 3=51$ so $K_1=2.$ We have $41-34<51-41$ so we take $x_2\equiv 17\cdot 2   \pmod {41}$ . That is, $x_2=-7$. Now we have $35=5|x_2|<41<6|x_2|=42$ so $K_2=5$. And $41-35>42-41$ so we take $x_3\equiv  (1+K_2)x_2  \pmod {41}.$ That is, $x_3= -1.$
Now modulo 41 we have  $-1\equiv (1+k_2)\cdot k_1\cdot 17 \equiv 6\cdot 2\cdot 17 \equiv 12\cdot 17.$ Therefore $1\equiv (-12)17\equiv 29\cdot 17.$ 
A: Saying that x is the multiplicative inverse of 17 mod 41 means that 17x= 1 (mod 41) which is equivalent to saying that 17x= 1+ 41n for some integer n.  That is the same as the "Diophantine equation" 17x- 41n= 1.
To solve that, use the "Euclidean division algorithm:
17 divides into 41 twice with remainder 7: 41- 2(17)= 7.
7 divides into 17 twice with remainder 3: 17- 2(7)= 3
3 divides into 7 twice with remainder 1:  7- 2(3)= 1.
Replace the 3 in that last equation with 17- 2(7): 7- 2(17- 2(7))= 5(7)- 2(17)= 1
Replace the 7 in that equation with 41- 2(17): 5(41- 2(17))- 2(17)= 5(41)- 12(17)= 1.
So one solution to 17x- 41n= 1 is x= -12, n= -5.  But x= -12+ 41k,n= -5+ 17k is also a solution for any integer k: 17(-12+ 41k)- 41(-5+ 17k)= -204+ (17)(41)k+ 205- (41)(17)k= 1.
Here, x must be non-negative and less than 41: take k= 1: x= -12+ 41= 29
A: Using Fermat's little theorem, $$17^{40}\equiv 1\pmod{41}\Rightarrow 17^{39}\cdot17\equiv 1\pmod{41}$$ Hence $17^{39}$ is the searched inverse. We have $$17^2\equiv 2\pmod{41}\Rightarrow
 17^{30}\equiv 2^{15}\equiv 9\pmod{41}$$
$$17^9\equiv(17^2)^4\cdot 17\equiv 16\cdot17\equiv26\pmod{41}$$Hence $$17^{39}\equiv9\cdot26\equiv 29\pmod{41}$$
Thus the inverse is $29$.
