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?
-
There is no problem; if 177 were prime then you could use Fermat's little theorem. – vadim123 Dec 16 '14 at 04:12
2 Answers
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$).
- 7,803
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.
- 6,206