Tricks for Find Modular Inverses I know that you can apply Euclid's Extended Algorithm, but I was wondering if there were "tricks" for guessing modular inverses. For example, if you have something like $ 13 \pmod{25}$ then you easily just guess $2$. But if you have something like $37 \pmod{12*18}$ is there a good way? I considered $6$, because 36 is one less than 37 and is a factor of 12*18, but that (obviously) gives $6$ not $1$. So are there other "tricks" for guessing modular inverses?
 A: No guessing is needed. Both are easy using Gauss's algorithm
$\qquad{\rm mod}\ 25\!:\ \ \ \dfrac{1}{13}\equiv \dfrac{2}{26}\equiv \dfrac{2}1$
$\qquad {\rm mod}\ 216\!:\ \dfrac{1}{37}\equiv \dfrac{5}{185}\equiv \dfrac{5}{-31}\equiv\dfrac{35}{-217}\equiv\dfrac{35}{-1}$
You can find many more examples (and other methods) in prior posts. Note that Gauss's algorithm won't always work for composite moduli, and you must keep all denominators coprime to the modulus (that's why I chose $5$ vs. $6$ in the 2nd example). See the linked posts for further details.
A: If you know the Chinese Remainder Theorem, it can help you to go about the task a bit more structured. Assume the modulus is $m = p_1^{e_1} \text{ ... } p_k^{e_k},$ with $(p_i, p_j) =1$ for all $i \ne j$ - in your case $m = 2^3 3^3.$ You seek an $x$ s.t. $$ax = 1 \text{ mod } m,$$ in your case $a = 37$. Because of the mutual co-primeness of your factors, you can re-write this as a joint system of linear equations, for $i = 1, \text{ ... }, k$:
$$ax = 1 \text{ mod } p_i^{e_i}.$$ By an early little theorem, the original equation and the system of equations have the same solution (it's an iff). There are many posts on the CRT on MSE and elsewhere; there are a few ways in which to solve the system efficiently. Note also that, instead of using an exponent $e_i$, you could use an exponent $j, 1 \le j \le e_i$ (by another lemma); so you have some choice what to simplify it to.   
Why is that easier? You reduced the modulus, and it is obviously easier to find a solution for a smaller modulus - often by inspection alone. So in the example mentioned, you see that the inverse of 37 mod 12*18 must also be an inverse of 37 mod 8 and mod 27. 
A: There is a simple trick for finding the modular inverses of small numbers.  For example, 2 is the easiest.  The inverse of 2 modulo any odd number $n$ is simply $\frac{(n-1)}{2}+1$.  This is easy to see, because $$2\cdot\left(\frac{(n-1)}{2}+1\right) = (n-1) + 2 = n+1 \equiv 1 \pmod n.$$
More generally, if you have two natural numbers $a$ and $b$, $a < b$, such that $b \equiv -1 \pmod a$ then the modular inverse of $a \pmod b$ is simply $\frac{(b\:-\:a\:+\:1)}{a}+1$.  For example, consider the problem of finding the inverse of 5 modulo 164.  It's easy to see that 164 when divided by 5 leaves a remainder of 4, which means 164 is congruent to -1 mod 5.  So the above formula for the modular inverse applies, and you can just plug the numbers in to get $\frac{(164\:-\:5\:+\:1)}{5}+1=33$, and as promised, $33\cdot5=165\equiv1\pmod{164}$.
However, if $b \not\equiv -1 \pmod a$, then you can still use the above trick if you can find a number $c$, $c<a$, such that $c\cdot b\equiv-1\pmod a$, because you can just substitute $c\cdot b$ into the formula above in the place of $b$.  To illustrate, consider the problem of finding the inverse of 5 mod 103.  Unlike 164, when you divide 103 by 5 you get a remainder of 3, not 4.  But, it's easy to see that $3\cdot 3 = 9 \equiv -1 \pmod 5$.  So we just multiply 103 by 3 to get 309, and use that number in the formula instead of 103.  So $\frac{(309\:-\:5\:+\:1)}{5}+1=62$, which is the multiplicative inverse of 5 modulo 103.
Unfortunately, the larger $a$ gets, the less likely it is that $b$ will be congruent to -1 modulo $a$, and the harder it is to find a multiple $c$ that works as above.  For example, in your question you ask what the inverse is of 37 modulo 216.  It's not too hard to determine that $216 \equiv 31 \pmod {37}$, but it's not instantly obvious (at least to me) what $c$ is such that $c\cdot 31 \equiv 36 \pmod{37}$.  Of course, if you can find the inverse of 31 modulo 37, then $c$ would be congruent to $36\cdot 31^{-1} \pmod {37}$. It happens to be that this is relatively easy in this case: $37 \equiv 6 \pmod{31}$, and trivially $6\cdot 5 = 30 \equiv -1 \pmod{31}$, so $c\equiv 36\cdot ((((37\cdot 5)-30)/31)+1) \equiv36 \cdot 6 \equiv 31 \pmod{37}$, so now we can substitute $31\cdot 216$ into the formula to find the inverse of 37 modulo 216 (it comes out to 181).  But frankly I get a little confused trying to do several layers like that in my head, and it was just luck that this example only needed two layers.  So in general, where the numbers aren't very small it's probably easier to just apply the Extended Euclidean Algorithm or the algorithm described above by Bill Dubuque.  But for small enough numbers I find it faster to use the trick above.
Note: if $a$ equals a small number raised to any natural number power, then you can again use the simple trick.  e.g. If instead of 37, you had asked about finding the inverse of 125 mod 216, then you just find the inverse of 5 mod 216 (it's 173), and so you can say that the inverse of 125 modulo 216 is $173^3$.
