🔍
🔄

Modular Arithmetic Calculator

Perform addition, subtraction, multiplication, or exponentiation under a modulus, and see each remainder mod n.

What modular arithmetic is

Modular arithmetic deals with remainders after division. When you compute a number “mod n”, you’re finding the remainder left over after dividing by n. It’s the same idea behind a 12-hour clock, where 13 o’clock wraps back around to 1.

How this calculator works

Enter two numbers, a, and b, choose an operation, and a modulus n. The calculator first performs the chosen operation (addition, subtraction, multiplication, or exponentiation) and then reduces the result modulo n, always returning a remainder between 0 and n-1 (even if your inputs are negative). For exponentiation, it repeatedly multiplies and reduces at each step, which is how modular exponentiation is done efficiently in practice.

This tool is intended for general math and computer science learning purposes.

Last reviewed August 2026