# Quick calculation of modulo with large exponent [closed]

In a correction of an exercise, the teacher simply wrote down

$$2^{107}\text{mod }187 = 161.$$

Is there any way for this to be so easily calculated?

## closed as off-topic by TheSimpliFire, José Carlos Santos, user91500, Adrian Keister, Arnaud D.Jan 16 at 16:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – TheSimpliFire, José Carlos Santos, user91500, Adrian Keister, Arnaud D.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Well, $187=11\times 17$ and it is easy enough to work out $2^{107}$ modulo each of those primes. That's a good start. – lulu Jan 21 '18 at 16:28
• – Arnaud D. Jan 16 at 16:57

We have $$2^{10}=1024\equiv89\pmod{187}$$ $$89^2=7921\equiv67\pmod{187}$$ $$67^2=4489\equiv1\pmod{187}$$ so $$2^{107}=2^{100}\cdot2^{7}=(2^{10})^{10}\cdot128\equiv89^{10}\cdot128\equiv67^5\cdot128\equiv67\cdot128=161\pmod{187}$$as desired.
use that $$2^{40}\equiv 1 \mod 187$$
• I don't have a problem, I asked a question: how can your remark help to get to the known answer? If @Atmos can do $2^{27}$ by mental calculation, that's fine, but most can't. – Professor Vector Jan 21 '18 at 16:38