Modulo Calculator
Remainder of a mod n with quotient and check, using mathematical or truncated conventions for negatives.
In short
Remainder of a mod n with quotient and check, using mathematical or truncated conventions for negatives.
Formula: a = n × q + r. Floored: q = ⌊a ÷ n⌋, so r has the sign of n. Truncated: q = trunc(a ÷ n), so r has the sign of a.
What this calculator does
Remainder of a mod n with quotient and check, using mathematical or truncated conventions for negatives. Formula, worked example, sources, FAQs and limitations included.
You enter dividend a (whole number), divisor n (whole number, not 0) and convention for negatives, and the modulo calculator shows the answer along with the working, so you can check it or try other numbers.
The page shows the formula, a numeric worked example, and the assumptions that affect this math calculation.
Inputs and what they mean
- Dividend a (whole number)
- — number value.
- Divisor n (whole number, not 0)
- — number value.
- Convention for negatives
- — choice value.
How to use it
- Enter each value in the unit shown next to the box (use the unit converter first if your numbers are in other units).
- Check the breakdown to see every intermediate step.
- Read the limitations before relying on the result.
Formula
Source: Wolfram MathWorld, Mod.
Both conventions agree when a and n are both positive.
a = n × q + r. Floored: q = ⌊a ÷ n⌋, so r has the sign of n. Truncated: q = trunc(a ÷ n), so r has the sign of a.
Inputs used: Dividend a (whole number), Divisor n (whole number, not 0), Convention for negatives.
Worked example
17 mod 5
- ⌊17 ÷ 5⌋ = 3.
- 17 − 5 × 3 = 2.
Reading the result
The headline figure is the main answer. Any breakdown underneath shows the parts that make it up, so you can check the working and see what changes when you adjust an input.
Limitations and assumptions
- Whole numbers within JavaScript's safe-integer range.
- Not modular inverse or modular exponentiation.
- Exact mathematical relationships, rounded for display. Check units and rounding before using a result in graded, engineering or financial work.
- The result depends on the values you enter for this modulo calculator; it does not supply missing rates, rules, prices, dates, or assumptions for you.
Reference: Wolfram MathWorld
Last reviewed:
Common questions
Why is −7 mod 3 sometimes 2 and sometimes −1?
Mathematical (floored) modulo gives 2; truncated remainder, used by C and JavaScript %, gives −1. Choose the convention you need.
Can I use decimals?
No. This calculator is limited to whole numbers to keep results exact.
What is modulo used for?
Clock arithmetic, checking divisibility, cyclic indexes, hashing and checksums.
How do I use the Modulo Calculator?
Enter the required values for Dividend a (whole number), Divisor n (whole number, not 0), Convention for negatives. The calculator applies the formula on this page and shows the main result with any supporting breakdown so you can check the arithmetic.
What formula does the Modulo Calculator use?
a = n × q + r. Floored: q = ⌊a ÷ n⌋, so r has the sign of n. Truncated: q = trunc(a ÷ n), so r has the sign of a. The visible formula section above lists the calculation path and the edge cases the page handles, so the result can be checked without relying on the form alone.
Can the Modulo Calculator be used for exact decisions?
Use it as a calculation aid, not as a substitute for checking the underlying rule, contract, policy, or professional advice that applies to your situation. When a result depends on local rules, personal details, prices, or dates, enter those values yourself and confirm them before acting.
Sources
Method based on Wolfram MathWorld.
Cite this page
Free Calculator. (2026, November 3). Modulo Calculator. https://freecalculator.tech/tools/modulo-calculator
"Modulo Calculator." Free Calculator, 3 Nov. 2026, https://freecalculator.tech/tools/modulo-calculator.
Modulo Calculator — Free Calculator, https://freecalculator.tech/tools/modulo-calculator
Related tools
Calculate percentages, proportions, and percentage change with a clear formula breakdown.
Calculate a value after a percentage increase and see the exact increase amount.
Calculate a value after a percentage decrease and see the exact reduction.