Having some trouble working my way back up the Extended Euclidean Algorithm. I'm trying to find the multiplicative inverse of $497^{-1} (mod 899)$. So I started working my way down first finding the gcd:
\begin{align} 899&=497\cdot1 + 402\\ 497&=402\cdot1 + 95\\ 402&=95\cdot4 + 22\\ 95&=22\cdot4 + 7\\ 22&=7\cdot3 + 1 \end{align} Now I work my way back up using the extended algorithm and substituting: \begin{align} 1&=22-(7\cdot3)\\ 1&=22-(95-(22\cdot4))\cdot3\\ 1&=22-(95-(402-(95\cdot4)\cdot4))\cdot3\\ 1&=22-(95-(402-((497-402)\cdot4)\cdot4))\cdot3\\ 1&=22-(95-(402-((497-(899-497))\cdot4)\cdot4))\cdot3\\ \end{align}
Am I going about this right? Do I just keep substituting up the chain? It gets difficult to follow for me. And Here's what the terms equal going up:
\begin{align} 7&=95-(22\cdot4)\\ 22&=402- ( 95\cdot4)\\ 95&=497- 402\\ 402&=899- 497\\ \end{align}