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?

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$.
