How to use a modulo calculator
Enter an integer in Dividend (a) and a nonzero integer in Divisor (n). Choose Modulo convention, then click Calculate. The result shows the quotient, remainder, formula, and calculation steps for Floored (Euclidean) or Truncated modulo.
- Enter an integer in Dividend (a) and a nonzero integer in Divisor (n).
- Choose Floored (Euclidean) or Truncated in Modulo convention.
- Click Calculate.
- Review the quotient, remainder, and entries under Steps.
- Click Copy result or Download result (.txt) to keep the plain-text result.
- Click Reset to clear both inputs and hide the result.
How to calculate a mod n
The calculator uses a mod n = a - n * q. The convention determines how it selects q, the quotient. With positive inputs, both choices produce the same remainder:
Dividend (a): 17
Divisor (n): 5
a mod n = 2
The result shows a check that n * q + r returns the dividend. The calculation uses exact integer arithmetic.
Floored vs truncated modulo
Modulo convention changes how the quotient is rounded when the signs differ. Floored (Euclidean) rounds toward negative infinity, so a nonzero remainder has the divisor's sign. Truncated rounds toward zero, so the remainder has the dividend's sign or is zero.
Dividend (a): -17
Divisor (n): 5
Floored (Euclidean): a mod n = 3
Truncated: a mod n = -2
A negative divisor changes the Floored (Euclidean) remainder's sign. Under Truncated, the remainder follows the dividend's sign.
What inputs does the modulo calculator accept?
Dividend (a) accepts positive, negative, and zero integers. Divisor (n) accepts positive or negative integers, except 0. Each value can contain up to 100 digits after an optional leading plus or minus sign.
Blank values, decimals, and other non-integer text are rejected. The calculator trims surrounding whitespace before validation. Changing either input or Modulo convention hides the previous result until you click Calculate again.
The calculation runs locally in your browser. The script does not transmit Dividend (a), Divisor (n), or Modulo convention.
What the remainder can help you check
Use the two conventions to compare remainder rules for negative values. Enter the same Dividend (a) and Divisor (n), change Modulo convention, and compare the quotient and entries under Steps.
The remainder can also be used when checking divisibility, wrapping a value in a fixed range such as clock arithmetic or array indexing, or working with cryptography and hashing. This calculator performs the arithmetic; it does not interpret the result for a particular application.
When to use another math calculator
Use the Math Calculators category when the calculation involves more than a remainder. Choose the Greatest Common Factor Calculator for the GCF or GCD of two or more integers, or the Least Common Multiple Calculator for an LCM. Choose the Number Theory Calculator for modular arithmetic alongside GCF, LCM, prime factorization, factorials, permutations, or combinations.
Frequently asked questions
How do I calculate a mod n?
Enter Dividend (a) and Divisor (n), choose Modulo convention, and click Calculate. The result shows the quotient, remainder, formula, and Steps.
What is the difference between floored and truncated modulo?
Floored (Euclidean) rounds the quotient toward negative infinity and gives a nonzero remainder the divisor's sign. Truncated rounds toward zero and gives the remainder the dividend's sign or makes it zero.
Can I use a negative divisor or zero?
You can use a positive or negative nonzero divisor. A divisor of 0 is rejected because modulo by zero is undefined.
Does the modulo calculator support decimals?
No. The calculator accepts integer values, so decimal values and other non-integer text are rejected.
How many digits can I enter in the modulo calculator?
Each Dividend (a) and Divisor (n) can contain up to 100 digits after an optional leading plus or minus sign. Longer values, decimals, and blank inputs are rejected.