Modular Arithmetic - what did I do wrong? I'm trying to solve 17y=1 (mod 57).
Since gcd(17,57)=1 and 1 divides 1, they are relatively prime (coprime) and so the modulus equation above indicates that there will be a solution (exactly one residue class of mod57).
My first attempt:
17y≡1 (mod57)
(17x9)y≡1x9 (mod57)
153y≡9 (mod57)
(57x2+39)y≡9 (mod57)
39y≡9 (mod57)
(39x3)y≡9x3 (mod57)
117y≡27 (mod57)
(57x2+3)y≡27 (mod57)
3y≡27 (mod57)
y≡9 (mod19)
But this means that y≡9, 26, 47 (mod57) are all answers but this is impossible since there should only be one residue class? Note that 17x9=153≡39 in mod57 ≠ 1
IF I repeat with different numbers, e.g. my second attempt, I was able to obtain the correct solution:
17y≡1 (mod57)
(17x20)y≡1x20 (mod57)
340y≡20 (mod57)
(57x6-2)y≡20 (mod57)
-2y≡20 (mod57)
(-2x29)y≡20x29 (mod57)
-58y≡580 (mod57)
(57x(-1)-1)y≡57x10+10 (mod57)
-y≡10 (mod57)
y≡-10≡57-10≡47 (mod57)
Testing shows that 47+57n is indeed the general solution.
So, what did I do wrong during my first attempt?
Many thanks!!
 A: Observe that 
$$17\cdot10=170=3\cdot57-1\implies 17\cdot10=-1\pmod{57}\implies $$
$$\implies-10=47=17^{-1}\pmod{57}$$
and thus
$$17y=1\pmod{57}\implies y=17^{-1}\pmod{57}=47\pmod{57}$$
and observe that indeed $\;47=9\pmod{19}\;$...and you don't have any contradiction, but you hadn't yet answered your question.
A: Hint $\ {\rm mod}\ 57\!:\,\ 17y\equiv 1\iff y\equiv \dfrac{1}{17}\equiv \dfrac{-56}{-40}\equiv \dfrac{7}{5}\equiv\dfrac{-50}{5}\equiv -10$

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

Remark $ $ Such fiddling often works well for small numbers. For larger moduli one may use the Extended Euclidean Algorithm. Given integers $\rm\,x,y\,$ it yields integers $\rm\,a,b\,$ such that $\rm\, ax+by = gcd(x,y)\ $ (Bezout's identity). Thus, when the gcd $=1,\,$ 
$$\ \rm ax+by = 1\ \Rightarrow\ ax\equiv 1\!\!\pmod y$$
yielding the inverse of $\rm\,x,\,$ modulo $\rm\,y,\,$ i.e. $\,
 \rm x^{-1} = 1/x\, \equiv\, a\pmod y$
