Modulo Calculator
Calculate the modulo (remainder) of division between two integers. Find quotient, remainder, and check divisibility.
What is modulo operation and how does it work?
Modulo (mod) finds the remainder after division. a mod b = remainder when a is divided by b. Example: 17 mod 5 = 2 because 17 / 5 = 3 remainder 2. Written as 17 = 5*3 + 2. Used in programming, cryptography, clock arithmetic (24-hour time uses mod 24).
What is the difference between modulo and remainder?
For positive numbers, modulo and remainder are the same. For negative numbers, they differ. Example: -17 mod 5 = 3 (modulo wraps to positive), but -17 % 5 = -2 (remainder in some languages). Modulo: result has same sign as divisor. Remainder: result has same sign as dividend. Math uses modulo, programming varies.
How is modulo used in real life?
Clock arithmetic: 15:00 + 10 hours = 1:00 (25 mod 24 = 1). Even/odd check: n mod 2 = 0 (even) or 1 (odd). Circular arrays: index mod array_length. Hash tables: hash mod table_size. Credit card validation: Luhn algorithm uses mod 10. Cryptography: RSA encryption uses modular arithmetic.
What does a mod b = 0 mean?
When a mod b = 0, it means a is divisible by b with no remainder. Examples: 15 mod 5 = 0 (15 = 5*3), 20 mod 4 = 0 (20 = 4*5), 100 mod 10 = 0. Used to check divisibility: if n mod d = 0, then d divides n evenly. Example: Is 144 divisible by 12? Yes, because 144 mod 12 = 0.
Can you do modulo with negative numbers?
Yes, but results vary by definition. Mathematical modulo: -17 mod 5 = 3 (always positive, 0 to 4). Formula: a mod b = a - b*floor(a/b). Symmetric modulo: can be negative. Example: -17 mod 5 = -17 - 5*(-4) = 3. In programming: Python: -17 % 5 = 3, JavaScript: -17 % 5 = -2 (different implementations).