Modulo Calculator

Calculate the remainder of integer division with step-by-step solutions

Home Categories Math Modulo Calculator

Expression:

mod

Modulo Properties Reference

Property Formula

Common Uses of Modulo

2

Even/Odd Check

n mod 2 = 0 (even) or 1 (odd)

12

Clock Arithmetic

hour mod 12 for 12-hour format

7

Day of Week

days mod 7 for weekday

n

Array Wrapping

index mod length for circular access

#

Hash Functions

hash mod buckets for distribution

🔐

Cryptography

RSA, Diffie-Hellman

Find this modulo calculator helpful?

Please help us simply by sharing it. It will help us a lot!

Share this Calculator

About Modulo Calculator

What is the Modulo Operation?

The modulo operation (often written as a mod n or a % n) finds the remainder when one integer is divided by another. If a = n × q + r, where q is the quotient and 0 ≤ r < n, then a mod n = r.

How to Use This Calculator

  1. Enter the Dividend (a): The number you want to divide
  2. Enter the Divisor (n): The number to divide by
  3. View Results: See the remainder with step-by-step breakdown
  4. Explore Examples: Try quick examples to understand the operation

The Formula

Modulo Operation: a mod n = r, where a = n × q + r

  • a = dividend (the number being divided)
  • n = divisor (the number to divide by)
  • q = quotient (integer part of a ÷ n)
  • r = remainder (the result of a mod n)

Properties of Modulo

Identity Property

a mod n = 0 when a is divisible by n

Range Property

0 ≤ (a mod n) < n for positive n

Distributive Property

(a + b) mod n = ((a mod n) + (b mod n)) mod n

Multiplicative Property

(a × b) mod n = ((a mod n) × (b mod n)) mod n

Common Applications

Programming

  • Checking even/odd: n % 2 equals 0 for even, 1 for odd
  • Array indexing: wrapping around circular buffers
  • Hash functions: distributing values across buckets

Cryptography

  • RSA encryption relies on modular arithmetic
  • Diffie-Hellman key exchange
  • Digital signatures

Time and Calendars

  • 24-hour to 12-hour conversion: hour % 12
  • Day of week calculations
  • Leap year calculations

Frequently Asked Questions

What happens when the dividend is negative?

For negative dividends, most calculators use floored division. For example, -7 mod 3 = 2 because -7 = 3 × (-3) + 2. This ensures the remainder is always non-negative when the divisor is positive.

What if the divisor is zero?

Division by zero is undefined, so a mod 0 is also undefined. The calculator will display an error for this case.

Is modulo the same as remainder?

In mathematics, modulo and remainder are often used interchangeably for positive numbers. However, for negative numbers, different programming languages may return different results based on their definition (truncated vs floored division).

What is modular congruence?

Two numbers a and b are congruent modulo n (written a ≡ b (mod n)) if they have the same remainder when divided by n. For example, 17 ≡ 5 (mod 12) because both give remainder 5.

Note: This calculator uses the mathematical definition of modulo with floored division, ensuring non-negative remainders for positive divisors.