Copied to clipboard!
Math Tools

Modulo Calculator

Calculate remainders and explore modular arithmetic

Modulo Calculator

Calculate the remainder when dividing two numbers

The number to be divided

The number to divide by

Quick Examples

Divisibility Checker

Check what numbers divide evenly into your number

Batch Modulo Calculator

Calculate multiple modulo operations at once

Modulo Table Generator

Generate a table showing modulo results for a range of values

Modulo Reference

Common applications and properties of modular arithmetic

Common Applications

Clock arithmetic (12-hour) mod 12
Day of week mod 7
Even/Odd check mod 2
Last digit of number mod 10
Byte overflow (8-bit) mod 256
Leap year check mod 4, 100, 400
Divisibility Rules
Divisible by 2 Last digit is even (0,2,4,6,8)
Divisible by 3 Sum of digits divisible by 3
Divisible by 4 Last 2 digits divisible by 4
Divisible by 5 Last digit is 0 or 5
Divisible by 6 Divisible by both 2 and 3
Divisible by 9 Sum of digits divisible by 9
Divisible by 10 Last digit is 0
Modulo Properties
Addition: (a + b) mod n = ((a mod n) + (b mod n)) mod n
Subtraction: (a - b) mod n = ((a mod n) - (b mod n)) mod n
Multiplication: (a × b) mod n = ((a mod n) × (b mod n)) mod n
Identity: a mod n = a, if 0 ≤ a < n
Periodicity: (a + n) mod n = a mod n
Programming Syntax
JavaScript / Java / C++ a % n
Python a % n
Excel / Sheets =MOD(a, n)
SQL a MOD n or a % n
Ruby a % n or a.modulo(n)

Understanding Modulo

What Is Modulo?

The modulo operation finds the remainder after division of one number by another.

  • Written as: a mod n or a % n
  • Result is always 0 to n-1
  • 17 mod 5 = 2 (17 = 5×3 + 2)
  • Used extensively in programming
Division Relationship

Modulo is related to integer division through the formula:

  • a = n × q + r
  • q = quotient (integer part)
  • r = remainder (modulo result)
  • 0 ≤ r < n (for positive n)
Negative Numbers

Different conventions exist for negative numbers:

  • Truncated: sign matches dividend
  • Floored: sign matches divisor
  • Euclidean: always non-negative
  • Languages differ in behavior