Free tools that run in your browser. Use any tool without an account.

Favourites Cart
Sign in
Join free

Modulo Calculator

  • Free
  • Runs in your browser
  • No account needed

a mod n is the remainder after dividing a by n. Example: 17 mod 5 = 2 because 17 = 5 × 3 + 2. The calculator shows floor quotient, C/JavaScript % result and Euclidean (never negative) remainder.

a mod n
2
Quotient (rounded down)
3
Check
17 = 5 x 3 + 2
Remainder with the sign of a (C, Java, JavaScript %)
2
Never negative (Euclidean)
2

For positive numbers all three agree. Whole numbers of any length are exact.

Runs in your browser. Your files and values are not sent to us. Report a problem
Advertisement

About the Modulo Calculator

You enter a Number (dividend) and a Divisor (modulus). The tool shows a mod n as the remainder, the quotient rounded down, a check identity, the C/Java/JavaScript style remainder and the Euclidean (never negative) remainder. Results update instantly as you type; there is no calculate button. The page runs entirely in your browser after it loads and nothing is uploaded. Whole integers of any length are exact. For positive inputs all three conventions agree. You can copy the result or share a link that reopens the page with your numbers. This keeps the tool fast, private and reliable for classroom work, programming checks and quick calculations.

How to use it

  1. 1Enter the Number (dividend) in the first field.
  2. 2Enter the Divisor (modulus) in the second field (nonzero).
  3. 3Read a mod n, Quotient (rounded down), Check and both remainder conventions.
  4. 4Copy the result or use the share link to reopen with the same inputs.
Advertisement

Worked example

Input: Number = -17, Divisor = 5. Output: a mod n = 3; Quotient (rounded down) = -4; Check: -17 = 5 × -4 + 3; C/Java/JavaScript % = -2; Euclidean (never negative) = 3.

The formula

a mod n is the remainder after dividing a by n: a = n x q + rHere q is rounded down (floor), so r has the same sign as nThis matches maths textbooks for positive n, Python's %, and Excel's MODC, Java and JavaScript round q towards zero instead, so their % takes the sign of aThe Euclidean version is never negative

Source: Division algorithm (LibreTexts)Python language reference (expressions and % behavior)JavaScript remainder operator (MDN). Last checked 7 November 2026.

What it is good for

  • Instant results as you type, no calculate button.
  • Shows both language-style % and the Euclidean never-negative remainder.
  • Runs in your browser and handles whole integers of any length exactly.
  • Does not perform modular inverse or modular exponentiation on this page.
  • Division by zero is undefined; the tool rejects a zero divisor.
Advertisement

Questions people ask

What exactly does a mod n mean?

a mod n is the remainder when you divide integer a by nonzero integer n. Mathematically you write a = n × q + r. With the floored quotient you get 0 ≤ r < |n| for the Euclidean remainder.

How do I compute a mod n by hand?

Divide a by n, take q = floor(a/n) (rounded down) and compute r = a − n × q. That r is the floored or Euclidean remainder, and matches Python's % and Excel's MOD for positive n.

Why does my program give a different remainder for negative numbers?

Languages differ. Python and Excel use floor-style remainders so r has the sign of the divisor. C, Java and JavaScript truncate the quotient toward zero so their % can take the sign of a. See the language docs for details.

What happens if I enter zero for the divisor?

Modulo by zero is undefined. The tool will reject a zero divisor and show an error because division by zero has no mathematical remainder.

Are results exact for very large integers?

Yes. Whole integer inputs of any length are handled exactly by this calculator. You can paste numbers with many digits and get precise quotients and remainders.

Can I save or share my calculation?

Yes. You can copy the displayed result and use the share link feature to reopen the page with the same inputs so others see the same output.

Help keep every tool free

FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.

Advertisement
Advertisement