17^7 mod 187
You asked:
MathBot Answer:
\[{17}^{7} \bmod 187 = 85\]
When dealing with an exponential expression, use the square-and-multiply algorithm to calculate the answer in a faster and easier way than evaluation and division.
First, find the binary representation of the exponent. The binary representation of \(7\) is \(\mathtt{\text{111}}\). Create rows corresponding to each digit of the binary representation.
Place the base in the row corresponding to the first binary digit. For each subsequent digit in the binary representation perform one of two operations:
- If the digit is 0, square the result from the previous row and calculate the result modulo \(187\).
- If the digit is 1, square the result from the previous row and calculate the result modulo \(187\). Multiply that result by the base and calculate the result of that operation modulo \(187\).
The result corresponding to the last digit in the binary representation is the answer.$$\begin{aligned}\mathtt{\text{1}}&\,\,\,|\,\, 17\\\mathtt{\text{1}}&\,\,\,|\,\, 17^2 \bmod 187 = 102, 102 \cdot 17 \bmod 187 = 51\\\mathtt{\text{1}}&\,\,\,|\,\, 51^2 \bmod 187 = 170, 170 \cdot 17 \bmod 187 = 85\end{aligned}$$The answer is \(85\).