0

How do I use the repeated squaring method to calcualte 2^176 (mod 177)? I'm not sure, but is there something about the fact that 177 is 1 greater than 176 that makes this a problem?

2 Answers2

1

Repeated squaring:

Compute $2^1,\ 2^2 = (2^1)^2,\ 2^4 = (2^2)^2,\ 2^8 = (2^4)^2$, etc, all modulo $177$.

$2^1 \equiv 2 \mod 177$

$2^2 \equiv 2*2 \mod 177 \equiv 4 \mod 177$

$2^4 \equiv 4*4 \mod 177 \equiv 16 \mod 177$

$2^8 \equiv 16*16 \mod 177 \equiv 256 \mod 177 \equiv 79 \mod 177$

and now we square $79$ instead of $256$:

$2^{16} \equiv 79*79 \mod 177 \equiv 6241 \mod 177 \equiv 46 \mod 177$

and now square $46$ next.

Etcetera.

Eventually you'll get to $2^{128}$, but the next square would take you over. So instead use what you've already computed: $176 = 128 + 32 + 16$ so $2^{176} = 2^{128} \cdot 2^{32} \cdot 2^{16}$ (but do this multiplication all modulo $177$).

aes
  • 7,803
0

If 177 was a prime, then you could have applied Fermat's little theorem, but it's composite, so you have to go through the computation. The first step is to write $176$ as a sum of powers of $2$: $176 = 2^7 + \dots$ Next you calculate $2$ to the power of each of these using repeated squaring. Finally, you multiply the powers together to get your answer.

user141592
  • 6,206