Modulo Calculator

Calculate modulo instantly in your browser.

Loading calculator…

What this tool does

Calculate modulo instantly in your browser. Try −17 mod 5: mathematical mode gives 3 (because −17 = 5×(−4) + 3) while programming mode gives −2.

How to use the Modulo Calculator

  1. Enter or select dividend a.
  2. Enter or select divisor b.
  3. Enter or select mode.
  4. Read the calculated result; change any measurement to compare alternatives.

Formula

a mod b is the remainder after division; mathematical mod always matches the divisor's sign while programming languages like JavaScript and C truncate toward zero, which changes negative cases.
a
Dividend a
b
Divisor b
mode
Mode

Try −17 mod 5: mathematical mode gives 3 (because −17 = 5×(−4) + 3) while programming mode gives −2.

Worked example

For modulo calculator, the following measurements illustrate the exact method: Dividend a: 17; Divisor b: 5; Mode: math.

Inputs

  • Dividend a17
  • Divisor b5
  • ModeMathematical (result has divisor's sign)

Result

  • a mod b2
  • Quotient (truncated)3
  • a ÷ b3.4

Results explained

a mod b
a mod b from the formula above. Try −17 mod 5: mathematical mode gives 3 (because −17 = 5×(−4) + 3) while programming mode gives −2.
Quotient (truncated)
Quotient (truncated) from the formula above. Try −17 mod 5: mathematical mode gives 3 (because −17 = 5×(−4) + 3) while programming mode gives −2.
a ÷ b
a ÷ b from the formula above. Try −17 mod 5: mathematical mode gives 3 (because −17 = 5×(−4) + 3) while programming mode gives −2.

Frequently asked questions

a mod b is the remainder after division; mathematical mod always matches the divisor's sign while programming languages like JavaScript and C truncate toward zero, which changes negative cases.

Try −17 mod 5: mathematical mode gives 3 (because −17 = 5×(−4) + 3) while programming mode gives −2.

Where mathematically meaningful, yes. Fields specify permitted ranges and undefined operations display an error.

Exact integer calculations use safe integers; decimal calculations use browser floating point, so small rounding differences can occur.

All values remain in your browser and are never uploaded.