Skip to main content
🔬 Advanced ✨ New

Калькулятор Остачі від Ділення

Calculate the remainder of a division operation. Find a mod b instantly with step-by-step explanation.

Як користуватися цим калькулятором

  1. Введіть Dividend (a)
  2. Введіть Divisor (b)
  3. Натисніть кнопку Розрахувати
  4. Прочитайте результат, відображений під калькулятором

What Is the Modulo Operation?

The modulo operation (mod, or %) returns the remainder after dividing one number by another. For a mod b: divide a by b, and the result is the remainder. For example, 17 mod 5 = 2 (because 17 = 3×5 + 2). The result is always in the range [0, b-1] for positive values.

The relationship: a = q×b + r, where q is the quotient (floor(a/b)) and r is the remainder (0 ≤ r < b). Modulo is the partner operation to integer division. If a ÷ b = 3 remainder 2, then a mod b = 2. Our calculator uses the true modulo definition (always non-negative) rather than the remainder-based definition used in some programming languages for negative numbers.

Modular arithmetic — arithmetic with a fixed modulus where numbers wrap around — forms the basis of clock arithmetic. Hours on a clock are calculated mod 12 or mod 24. If it's 10 AM and you add 5 hours: (10 + 5) mod 12 = 3 PM. This 'wrap-around' behavior is central to many algorithms in computer science and cryptography.

Applications of Modular Arithmetic

Modulo appears everywhere in programming and mathematics. Even/odd check: if n % 2 == 0, n is even. Circular arrays and buffers: index = (current_index + 1) % array_size wraps around to the beginning. Hash tables: bucket = hash(key) % num_buckets maps any hash value to a valid bucket index.

In calendar calculations, day-of-week arithmetic uses mod 7. The Zeller formula and Doomsday algorithm both rely heavily on modular arithmetic to determine what day of the week any date falls on. These work because there are exactly 7 days in a week — a fixed modulus.

In cryptography, modular exponentiation (a^b mod n) is the core of RSA encryption, Diffie-Hellman key exchange, and elliptic curve cryptography. The security relies on the discrete logarithm problem: given a^b mod n, finding b is computationally infeasible for large n. This asymmetry (easy to compute forward, hard to reverse) underpins most public-key cryptography.

Modulo with Negative Numbers and Edge Cases

Modulo behavior with negative numbers varies by programming language, which causes many bugs. In mathematics, modulo is always non-negative: -7 mod 3 = 2 (since -7 = -3×3 + 2). But in languages like C, Java, and Python (for the % operator), the remainder takes the sign of the dividend: -7 % 3 = -1 in C/Java. Python uses true modulo: -7 % 3 = 2.

The safe way to ensure a non-negative result in any language: ((a % b) + b) % b. This handles negative inputs correctly and is used in our calculator. This pattern is essential when using modulo for array indexing or day calculations where negative results would cause errors.

Special cases: any number mod 1 = 0 (dividing by 1 always leaves no remainder). Any number mod itself = 0. 0 mod any non-zero number = 0. Division (and modulo) by zero is undefined — always check for zero divisors before computing modulo.

Останнє оновлення: March 2026

Frequently Asked Questions

What is 15 mod 4?

15 mod 4 = 3. Because 15 = 3×4 + 3, the remainder is 3. Verify: 3×4 = 12, and 15 - 12 = 3. ✓

What does mod 0 mean?

Modulo by zero is undefined, just like division by zero. You cannot calculate a mod 0. Our calculator returns an error message in this case.

How does modulo relate to divisibility?

A number a is divisible by b if and only if a mod b = 0. For example, 24 mod 6 = 0, so 24 is divisible by 6. 25 mod 6 = 1, so 25 is not divisible by 6.