Every ladder row begins by squaring the prior result and reducing modulo m. The multiply choice happens after that.

highlighted = computed this step

Carry the prior result

Before this row, the prior result is 7.

rprior=7r_{\text{prior}}=7
Square stepThe ladder rows are recomputed from pinned base, exponent, and modulus.Square step - 7^13 mod 33stepbitpriorsquaremultiplyresult01117711716131320134skip4314161313

Why squaring advances the scan

Reading one more exponent bit doubles the exponent value already represented. Squaring is the modular way to make that advance.

next bit starts with a square\text{next bit starts with a square}
Square stepThe ladder rows are recomputed from pinned base, exponent, and modulus.Square step - 7^13 mod 33stepbitpriorsquaremultiplyresult01117711716131320134skip4314161313

Square and reduce

Squaring gives 7 times itself, reduced modulo 33 to 16.

77mod33=167\cdot7\bmod{}33=16
Square stepThe ladder rows are recomputed from pinned base, exponent, and modulus.Square step - 7^13 mod 33stepbitpriorsquaremultiplyresult01117711716131320134skip4314161313

Square happens first

The square value 16 is computed before checking whether this bit multiplies by the base.

square=16\text{square}=16
Square stepThe ladder rows are recomputed from pinned base, exponent, and modulus.Square step - 7^13 mod 33stepbitpriorsquaremultiplyresult01117711716131320134skip4314161313

Carry the row result forward

After the multiply decision, this row result 13 becomes the next row's prior result 13.

131313\to13
Square stepThe ladder rows are recomputed from pinned base, exponent, and modulus.Square step - 7^13 mod 33stepbitpriorsquaremultiplyresult01117711716131320134skip4314161313

Summary

Every ladder row starts with a square-and-reduce step, then carries one small remainder forward.

priorsquare\text{prior}\to\text{square}
Square stepThe ladder rows are recomputed from pinned base, exponent, and modulus.Square step - 7^13 mod 33stepbitpriorsquaremultiplyresult01117711716131320134skip4314161313