Ҳар қандай математика муаммосини ҳал қилиш
Мувозанат, ҳосил қилувчи, интеграл, матрица, учбурчак, аник, статистика - ёки ўқитувчи қисмларга ажратган сўз муаммоси.
Қадамма-қадам
- 2^{5} \bmod 5
Never compute the huge power. Reduce after every multiplication (repeated squaring).
- 2 \equiv 2 \pmod{5}
Reduce the base first.
- 5 = 101_2
Write the exponent in binary: 3 squarings at most.
- r \leftarrow r \cdot 2 \equiv 2 \pmod{5}
This bit is 1: multiply the result by the current power.
- 2^2 \equiv 4 \pmod{5}
Square the running power.
- 4^2 \equiv 1 \pmod{5}
Square the running power.
- r \leftarrow r \cdot 1 \equiv 2 \pmod{5}
This bit is 1: multiply the result by the current power.
- 2^{5} \equiv 2 \pmod{5}
Done.
Жавобни кўрсатиш
2^{5} \bmod 5 = 2