Toggle language
Toggle theme

Modulo Calculator

Calculate remainders, perform modular arithmetic, check congruence, and use practical applications like Luhn algorithm validation.

%Modulo Calculator

Calculate the remainder when a is divided by n. Result: a = q × n + r

How to Use the Modulo Calculator

Select an operation type: basic modulo, modular arithmetic, congruence check, or practical applications. Enter your numbers and click Calculate.

Calculator Modes

Basic Modulo

Calculate the remainder when dividing one number by another:

  • a mod n: The remainder when a is divided by n
  • Quotient: How many times n fits into a
  • Division Expression: a = q × n + r

Modular Arithmetic

Advanced modular operations used in cryptography and number theory:

  • Modular Exponentiation (b^e mod m): Calculate large powers efficiently
  • Modular Inverse (a⁻¹ mod m): Find x where a × x ≡ 1 (mod m)

Congruence Check

Two numbers a and b are congruent modulo m (written a ≡ b (mod m)) if they have the same remainder when divided by m. Equivalently, (a - b) is divisible by m.

Applications

Practical uses of modulo arithmetic:

  • Luhn Algorithm: Validate check digits for credit cards, ISBNs, IMEIs
  • Day of Week: Calculate the weekday for any date using Zeller's congruence

What is Modulo?

The modulo operation (mod) returns the remainder after division. For example, 17 mod 5 = 2 because 17 = 3 × 5 + 2. It's fundamental in computer science and mathematics.

Common Applications

  • Cryptography (RSA, Diffie-Hellman)
  • Hash functions and data structures
  • Check digit validation (credit cards, barcodes)
  • Circular buffers and wrap-around logic
  • Calendar calculations
  • Random number generation

Key Properties

  • (a + b) mod n = ((a mod n) + (b mod n)) mod n
  • (a × b) mod n = ((a mod n) × (b mod n)) mod n
  • a ≡ b (mod n) means n divides (a - b)
  • Modular inverse exists only when gcd(a, n) = 1