Modular exponentiation references

367 Views Asked by At

I have recently learned a trick in modular exponentiation that is new to me. By example (as in the linked question/answer above):

$$2^{1386}=2^{2^{10}}\cdot 2^{2^8}\cdot 2^{2^6}\cdot 2^{2^5}\cdot 2^{2^3}\cdot 2^{2^1}\equiv 2^{2^6}\cdot 2^{2^5}\cdot 2^{2^4}\cdot 2^{2^3}\cdot 2^{2^2}\cdot 2^{2^1}\pmod {1387}$$

since it was found that $2^{2^7}\equiv 2^{2^1}\pmod {1387}.$

After a little thought, I stumbled upon the notion that changing the exponentiation base from $2$ to $3$ might yield a similar result, and in fact I found that

$$1386_{10}=10101101010_2=1220100_3$$

Nothing spectacular about this, except when computing $2^{1386}\pmod{1387}$ using a cubing operation instead of squaring:

$$2^3=8\\ 8^3=512\\ 512^3\equiv 512\pmod{1387}$$

So we have that $2^{3^3}\equiv 2^{3^2}\pmod{1387}$, which means that

$$2^{3^6+2\cdot 3^5+2\cdot 3^4+3^2}\equiv 2^{6\cdot 3^2}\equiv 2^{2\cdot 3^3}\equiv 2^{2\cdot 3^2}\equiv 512^2\equiv 1\pmod{1387}$$

This seems to be a very useful result. Using repeated squaring, it took $7$ steps to identify a repeat point like this.

Are there any good references on this particular feature of modular exponentiation? In this question I was attempting to apply the above logic to Mersenne Primes (without success).

One obvious difficulty with this process is that there is no guarantee that a given base will produce effective results; this was especially true in my trials with Mersenne Primes, where finding an exponent that would produce a "small" repeat proved very difficult. So I would like to get information on the theory surrounding this topic to perhaps improve my calculations.