HomeCalculatorsMathNumber Theory & Discrete MathModulo Calculator
Math calculator

Modulo Calculator

Integer remainder with a = q·m + r and 0 ≤ r < |m|. Euclidean convention, not JavaScript truncated %.

Instant result
Result

Enter values to calculate.

Inputs
Mode
Formula
Trust summary Engine tested · Specification checked · 9/9 tests · Production surface contract 4/4 · v1.0.0
Input interpretation
Enter values to calculate.
Result
Model
Euclidean quotient and remainder for integers a and m ≠ 0.
Scope
Euclidean remainder
Verification
Engine tested · 9/9 tests · Production surface contract 4/4 · Specification checked · v1.0.0
Named expert review
Optional · Not performed
Specification basis
  • ISO 80000-2:2019 Quantities and units — Mathematics (integer division / remainder)
  • Knuth, The Art of Computer Programming, Euclidean division (remainder ≥ 0)
Specification basis
Evidence
2 golden · 2 boundary · 5 property · Production surface contract 4/4 · Artifact integrity PASS
Production
Embedded snapshot: unpublished · Build schema 1.0.0 ready · Semantic contract ✓ · Attestation report not published on origin · Live production status PASS (0 stale; 164 CURRENT) @ 2026-09-16T06:44:24.909Z
Semantic contract
PASS

Formulas

Core equations used by this calculator.

Identitya = q · m + r
Remainder range0 ≤ r < |m|
iShareable URLs use a and modulus. Do not use m in the query string — m is reserved on other calculators. REST still accepts m as an alias.

How to use

1

Enter dividend a

Any integer, including negative values.

2

Enter a non-zero modulus

The remainder is always in [0, |m|), even when m is negative.

3

Read remainder and quotient

Check a = q·m + r.

Example calculations

Common configurations with formula and result.

ϟ

Positive remainder

17 divided by 5

17 = 3·5 + 2
r=2
ϟ

Negative dividend

JavaScript (−17)%5 is −2; Euclidean remainder is 3

−17 = (−4)·5 + 3
r=3
ϟ

Negative modulus

Remainder still in [0, |m|)

17 = (−3)·(−5) + 2
r=2

Modulo calculator specification

Version 1.0.0 · Engine tested

Calculation status

Review policy · Evidence

Definition
Euclidean division writes a = q·m + r with remainder r satisfying 0 ≤ r < |m|. This is not JavaScript’s truncated remainder operator.
What it calculates
Euclidean quotient and remainder for integers a and m ≠ 0.
Inputs
  • a
  • modulus
Outputs
  • remainder
  • quotient
  • identity
Formula
a = q·m + r, 0 ≤ r < |m|
Assumptions
  • Euclidean remainder
  • Not JavaScript truncated %
  • Integers only
Units
  • dimensionless
Boundary conditions
  • missing a or modulus → MISSING_REQUIRED_INPUT
  • modulus = 0 → DIVISION_BY_ZERO
Example
a=-17 modulus=5 → remainder=3
Validation cases

3 published on this page · 9/9 tests · Production surface contract 4/4 · View evidence

  • a=17 modulus=5 → remainder=2
  • a=-17 modulus=5 → remainder=3
  • a=10 modulus=0 → error DIVISION_BY_ZERO
Specification basis
  • ISO 80000-2:2019 Quantities and units — Mathematics (integer division / remainder)
  • Knuth, The Art of Computer Programming, Euclidean division (remainder ≥ 0)
Calculation version
1.0.0
}

Frequently asked questions

Key distinctions behind the calculation.

Why is (−17) mod 5 equal to 3, not −2?

This page uses the Euclidean remainder. Remainders are never negative. JavaScript % truncates toward zero, so (−17)%5 is −2.

Is this floating-point remainder?

No. Integers only. Not IEEE remainder and not fmod.

Where does this run?

Locally in the browser by default. REST and MCP call the same modulo engine.