Practical guide and verification
Read the expression as repeated modular reduction
The goal is a^b mod n, not to construct a^b as one enormous integer first. Square-and-multiply repeatedly reduces intermediate values modulo n, keeping the computation practical even when the exponent is large.
Require a positive modulus
A modulus of zero has no valid remainder operation, and cryptographic or number-theory conventions normally use a positive modulus. If the base is negative, the canonical nonnegative residue should still lie from zero through n minus one.
Verify small cases by ordinary arithmetic
For a manageable exponent, compute the power independently and divide by the modulus to check the remainder. For larger exponents, use the displayed square-and-multiply rows to confirm each squaring or multiplication is followed by reduction.
Distinguish modular exponentiation from a cryptographic proof
The arithmetic is used inside RSA, Diffie-Hellman, primality tests, and many algorithms, but a correct residue does not validate a key, prove a number prime, or make an arbitrary protocol secure. Those tasks require additional rules.
Preserve exact integers when copying evidence
These calculations are integer operations. Avoid spreadsheet or programming environments that silently round very large integers to floating point. Copy the exact base, exponent, modulus, and residue when reproducing the result elsewhere.