[Math] Arithmetic with Large modular exponent and repeated squaring, such as $10^{221}$ (mod $13$).

discrete mathematicselementary-number-theorymodular arithmetic

How would you compute $10^{221}$ mod $13$ by repeated squaring? I just started studying discrete mathematics and I think this would help me in the future. I looked at this example Computing large modular numbers but it kind of didn't make sense to me. Also how could you use Fermat's Little Theorem for this question. Note that I made this questions up myself so I hope it works.

Best Answer

First, find $10^2 \pmod{13}=9$. Find $10^4=(10^2)^2\equiv 9^2\equiv 3 \pmod{9}$. Find $10^8=(10^4)^2\equiv 3^2\equiv 9 \pmod{13}$. Find $10^{16}, 10^{32}, 10^{64}, 10^{128}$ by continuing in this fashion. Lastly, write $221$ in base $2$ as $221=128+64+16+8+4+1$. Hence, we can find $10^{221}=10^{128}10^{64}10^{16}10^{8}10^410^210^1$, and we take the whole thing mod $13$ to get $4$.

Related Question