It's easy to compute an inverse $\!\bmod n\:\!$ of a factor $\,a\,$ of $\,n\!-\!1,\,$ i.e. $\,n\!-\!1=ba,\,$ so
Easy Inverse: $\bmod n = ba\!+\!1\!:\,\, -ba \equiv \ 1 \,\Rightarrow\, a^{-1}\equiv -b.\,\ $ OP is $\,a,b = 5,2.$
So the inverse is computable by a $\rm\color{#c00}{single\ division}$ $\ \,a^{-1}\equiv -b = (n\!-\!1)/a$.
Similarly we've $\ \bmod n = ba\!-\!1\!:\ \ \ \ ba\,\equiv\, 1\, \Rightarrow $ $\,a^{-1}\,\equiv\:\ b= \:\!(n\!+\!1)/a$.
Generally we can use the Extended Euclidean Algorithm or Gauss's algorithm to compute modular inverses and fractions, e.g. see here and here. The above easy inverse formula is an optimization (of the case when the algorithms terminate in a $\rm\color{#c00}{single\ step}$). The analogous double step optimization is inverse reciprocity. Both prove convenient in manual calculations.