Modular Arithmetic Calculator

Compute a mod n, modular addition, multiplication and power (aᵇ mod n) — clock arithmetic made instant.

927 views

Clock Arithmetic

a mod n is the remainder of a ÷ n — like a clock that wraps at n: 17 mod 12 = 5. The tool also computes (a + b) mod n, (a × b) mod n and the powerhouse of cryptography, aᵇ mod n, using fast square-and-multiply with big integers so even huge exponents are exact.

Frequently Asked Questions

What is −7 mod 3?

This tool follows the mathematical convention where the result is always non-negative: −7 mod 3 = 2 (since −7 = −3×3 + 2). Some programming languages return −1 instead.

Where is aᵇ mod n used?

It is the core operation of RSA and Diffie-Hellman: encrypting a message essentially means computing a huge modular power.

Similar Tools