Let's use this algorithm to raise 3 to the power 7.
- P1: raise 3 to the power 2 (choose I=2, no particular reason).
- P2: raise 3 to the power 5 (7-2=5).
- P2.1: raise 3 to the power 1. (choose I=1)
- P2.2: raise 3 to the power 4 (5-1=4).
- P2.2.1: raise 3 to the power 2.
- Solve directly: S2.2.1=9.
- P2.2.2: raise 3 to the power 2.
- Solve directly: S2.2.2=9.
- Combine: S2.2 = S2.2.1 * S2.2.2 = 9 * 9 = 81.
- Combine: S2 = S2.1 * S2.2 = 3 * 81 = 243.
- Combine: S = S1 * S2 = 9 * 243 = 2147.