Modulo Calculator

Remainder, quotient, and check for integer division A mod N.

Math and PercentUpdated 2026-10-112 min read
Modulo Calculator
Number being divided.
Non-zero whole modulus.
Remainder
...
Quotient...
Check...

What it does

Modulo answers the leftover question after division. Seventeen cookies across five bags fill three full bags with two cookies spare, so 17 mod 5 is 2. The tool above prints that remainder with the quotient and a multiply back check.

The default divides 17 by 5 for quotient 3 remainder 2, verified as 3 x 5 + 2 = 17. The same pattern powers clocks, calendars, and code: even numbers are 0 mod 2, week cycles run mod 7, and hash tables scatter keys by mod table size.

Negatives follow the floored convention here, matching standard math texts. Minus 17 mod 5 is 3, because -4 x 5 + 3 rebuilds -17 with a non-negative remainder. Some programming languages return -2 instead, which this page deliberately avoids so remainders stay inside 0 to N minus 1.

Zero divisors have no answer in any convention, and the tool says so instead of guessing. Huge values up to a trillion stay exact; past that, floating point starts lying about units, so the page stops first.

How to use

  1. Type the whole dividend A.
  2. Type the whole non-zero divisor N.
  3. Read the remainder first.
  4. Read the quotient beside it.
  5. Multiply back with the check line to confirm.

Formula

A = q x N + r with 0 <= r < N. Here q = floor(A / N).
A
Dividend being split.
N
Divisor; absolute value sets the range.
r
Remainder from 0 to N minus 1.

Floored division throughout, per standard number theory texts. Truncated remainders from some languages differ on negatives and are not used here.

Worked example

Example: 17 mod 5

Defaults: A 17, N 5.

  1. Divide: 17 / 5 = 3.4, floor to 3.
  2. Multiply: 3 x 5 = 15.
  3. Subtract: 17 minus 15 = 2.
  4. Range check: 2 sits inside 0 to 4.
  5. Tool shows 2, 3 r 2, 3 x 5 + 2 = 17.

Reference table

Small remainders
DivisionQuotientRemainder
7 mod 32 r 11
10 mod 42 r 22
15 mod 53 r 00
23 mod 73 r 22

Limits

  • Whole numbers only; decimals round first.
  • Non-zero divisors; zero has no remainder.
  • Magnitudes cap at a trillion for exactness.
  • One convention shown; code % may differ on negatives.

Common mistakes

  • Dividing by zero and expecting zero.
  • Reading the quotient as the answer.
  • Assuming negatives stay negative.
  • Mixing mod with percent of amounts.
  • Trusting float division past a trillion.

Try it yourself

Quick checks. Answers sit tucked under each question.

100 mod 7?

14 x 7 + 2 = 100, so remainder 2.

20 mod 6?

3 x 6 + 2 = 20, so remainder 2.

-17 mod 5?

-4 x 5 + 3 = -17, so remainder 3.

Questions

What is 17 mod 5?

2, since 3 x 5 + 2 = 17.

What about negative numbers?

This page floors, so -17 mod 5 is 3, always 0 or more.

Why do languages disagree?

Many truncate toward zero; math texts floor toward minus infinity.

Modulo or percent?

Modulo here is remainder math, not hundredths of an amount.

What is anything mod 1?

Always 0, since 1 divides everything evenly.

Where is modulo used?

Clocks, calendars, checksums, hashing, and ciphers.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.