Math Tools

Modulo Calculator

Find a mod n with the quotient, the programming remainder and the true mathematical modulo.

  • 2a mod n
  • 2Remainder (%)
  • 3Quotient

The modulo always matches the divisor's sign; the remainder matches the dividend's.

How to use it

  1. Enter the dividend The number being divided (a).
  2. Enter the divisor The number you divide by (n).
  3. Read both results The mathematical modulo and the remainder.

Examples

17 mod 5 2
−17 mod 5 3 (or −2)

About this tool

The modulo operation gives the remainder after division, but there’s a subtlety: the answer for negative numbers depends on the convention. This calculator shows both — the remainder as most programming languages compute it, and the true mathematical modulo that’s always non-negative for a positive divisor.

It also reports the quotient, so you can see the full picture of the division. Whether you’re debugging code or working through number theory, having both conventions side by side removes the guesswork. It runs entirely in your browser.

Frequently asked questions

Why are there two results?

Many programming languages' % operator keeps the sign of the dividend, while the mathematical modulo keeps the sign of the divisor. For negative inputs these differ.

What about negative numbers?

For −17 mod 5, the remainder is −2 but the mathematical modulo is 3. The tool shows both so you can pick the one you need.

Related tools

Updated June 14, 2026