As pointed by poncho, for finding the inverse of $5$ there is a better method $$(n+1)/5, (2n+1)/5, (3n+1)/5, (4n+1)/5$$ if the inverse exist. To see the inverse exist, one first needs to see that the $\gcd(5,n)=1$.

In the general case, after some threshold, this approach may not be helpful, since testing all $$(n+1)/x, (2n+1)/x, \ldots, ((x-1)n+1)/x$$ will pass the calculation of the Bézout's identity.

$\begingroup$Even easier way to find $5^{-1}$ (if it exists); it's the one of $(n+1)/5, (2n+1)/5, (3n+1)/5, (4n+1)/5$ that's an integer. Obviously, this doesn't scale for finding $x^{-1}$ for large $x$; for $x=5$, it works...$\endgroup$
– ponchoMar 25 at 19:39

$\begingroup$@poncho Thanks, extended a bit with this trick.$\endgroup$
– kelalakaMar 25 at 19:56