MathIsimple
Modulo Calculator

Modulo Calculator

Calculate modulo operations (a mod b) with step-by-step explanations. Perfect for programmers, math students, and anyone working with remainder calculations.

100% FreeStep-by-stepProgramming Examples
Modulo Operation Calculator
Calculate the remainder of integer division (a mod b)
Formula
amodb=ab×a/ba \bmod b = a - b \times \lfloor a / b \rfloor

Where a is the dividend and b is the divisor

The number being divided (can be negative)

The number to divide by (cannot be zero)

17mod5=?17 \bmod 5 = ?
Example Calculations
Common modulo operations and their results
17 mod 5

Basic positive modulo

Result: 2
13 mod 12

Clock analogy (1 o'clock)

Result: 1
25 mod 12

Multiple circles

Result: 1
42 mod 10

Programming example

Result: 2
1000 mod 7

Large number modulo

Result: 6
8 mod 3

Small divisor

Result: 2
What is Modulo Operation?

The modulo operation finds the remainder after division of one number by another. It's denoted as a mod b or a % b in programming.

Key Properties:

  • Result is always 0 ≤ r < |b| for positive divisor
  • a mod b = a - b × floor(a / b)
  • If a is divisible by b, then a mod b = 0
  • The sign of the result depends on the divisor

Applications:

  • Programming: Array indexing, hash functions
  • Mathematics: Number theory, cryptography
  • Real world: Clock arithmetic, calendar calculations
How to Calculate Modulo by Hand

For Positive Numbers:

  1. Divide a by b using integer division
  2. Find the quotient (whole number part)
  3. Multiply quotient by divisor
  4. Subtract from original dividend

For Negative Numbers:

  1. Use the formula: a mod b = a - b × floor(a / b)
  2. Calculate floor(a / b) carefully
  3. floor(-5/2) = floor(-2.5) = -3
  4. -5 mod 2 = -5 - 2×(-3) = -5 + 6 = 1

Remember: The mathematical definition ensures the result is always non-negative when the divisor is positive.

Modulo in Programming & Math

Programming

  • Array index wrapping: i % array.length
  • Even/odd check: n % 2 == 0
  • Circular buffer: (index + 1) % bufferSize
  • Hash table indexing: hash % tableSize

Mathematics

  • Modular arithmetic: (a + b) mod m
  • Cryptography: RSA encryption
  • Number theory: GCD calculations
  • Congruence relations: a ≡ b (mod m)

Real World

  • Clock arithmetic: (hour + n) % 12
  • Day of week: day % 7
  • Circular patterns: step % cycle
  • Remainder calculations
Modulo Calculator - Compute a mod b Remainder Easily | MathIsimple