About the Modulo Calculator
Calculate a mod n for positive and negative numbers using the mathematical (always non-negative) definition.
Also known as: mod calculator, modulus calculator, a mod b, modular operation.
How to use this calculator
- Enter a, n (modulus).
- The result updates instantly as you type — press Calculate (or Enter) at any time.
- Open “Step-by-step” to see how the answer was worked out.
- Use Copy result or Share to save the answer or send a link with your inputs.
Formula
a mod n = a − n × ⌊a / n⌋
Worked example
Using the values pre-filled in the calculator above:
- a = -17
- n (modulus) = 5
the calculator returns:
- -17 mod 5: 3
- Truncated remainder (JavaScript/C %): -2
Working
-17 = 5 × -4 + 3