I have to find the modular inverse of a sequence of numbers. When I do the inverse of $5\pmod {37}$, I get $-7$. $$37 = 7(5)+2$$ $$5 = 2(2)+1\text{, then}$$ $$2 = 1(37)-7(5).$$
so the inverse is $-7.$
But $-7\times 5 \pmod{37}$ is $2$. Shouldn't it be $1$?
I need to use this value for two later problems so it's messing it all up.
$$37=7(5)+2$$ $$5=2(2)+1$$ $$2=1(1)+1$$ then $$1=5−2(2)$$ $$1=5−2(37−7(5))$$ $$1=12(5)−2(37))$$
– user48812 Nov 09 '12 at 18:22