Modulo Calculator

Enter a dividend and a divisor to get a mod n, the remainder and the quotient. For negative numbers, programming languages disagree, so both answers are shown with the check q × n + r = a.

-17 mod 5

3

Floored: same sign as 5

Remainder -17 % 5

-2

Truncated: same sign as -17

Exact division

-3.4

Quotient and check

MethodQuotient qResult rq × n + r = a
Floored modulo (Python %, Excel MOD)-43-4 × 5 + 3 = -17
Truncated remainder (C, Java, JavaScript %)-3-2-3 × 5 + -2 = -17

Features

  • a mod n and the remainder, side by side

  • Integer quotient for each method

  • Works for negative numbers and decimals

  • Check line: quotient × divisor + result = dividend

  • Says when a number divides exactly

When to use it

Programming

See what % returns in JavaScript or Java compared with Python for negative values.

Maths homework

Division with remainder and modular arithmetic for number theory.

Clocks and calendars

Wrap-around sums: 30 hours after 22:00 is (22 + 30) mod 24 = 4:00.

Frequently Asked Questions

Worked examples

a n a mod n (floored) a % n (truncated)
17 5 2 2
-17 5 3 -2
17 -5 -3 2
-17 -5 -2 -2

Related: LCM and HCF Calculator, Fraction Calculator, Roman Numeral Converter.