Modulo Calculator
Find a mod n — the remainder after division — with both the math (always positive) and programming conventions.
a mod n
2
- Truncated remainder (a % n in code)
- -1
- Integer quotient
- -3
Show the work
Divide, then round down
q = ⌊a ÷ n⌋
⌊(−7) ÷ 3⌋ = −3
Take away n × q
a mod n = a − n × q
(−7) − 3 × (−3) = 2
How it works
a mod n = a − n × ⌊a ÷ n⌋ (math, result has the sign of n); truncated remainder = a − n × trunc(a ÷ n) (C, Java, JavaScript %)
Questions
- How does the modulo calculator work?
- a mod n = a − n × ⌊a ÷ n⌋ (math, result has the sign of n); truncated remainder = a − n × trunc(a ÷ n) (C, Java, JavaScript %).
- What do I need to enter?
- Dividend (a), Divisor (n). Optional fields can be left blank.
Related tools
- Quadratic Equation SolverSolve ax² + bx + c = 0 for real or complex roots, with the discriminant and vertex.
- Cubic Equation SolverSolve ax³ + bx² + cx + d = 0 for all three roots, real or complex.
- FOIL CalculatorMultiply two binomials (ax + b)(cx + d) with the FOIL method and see each step.
- Completing the Square CalculatorRewrite ax² + bx + c in vertex form a(x − h)² + k by completing the square.
- Fraction, Decimal & Percent ConverterConvert between fractions, decimals and percents — type any one, get all three, including repeating decimals.
- Ratio to Fraction CalculatorTurn a ratio like 3 : 5 into fractions of the whole, percentages and the simplified ratio.
Want this on your site? Embed the modulo calculator.