Modulo Calculator

a mod b

Quotient

Explanation

Understanding the Modulo (Remainder) Operation

The modulo operation (often written as a mod b or a % b) returns the remainder when one integer is divided by another. For example, 17 mod 5 = 2 because 17 divided by 5 is 3 with a remainder of 2. The result always falls between 0 and b-1 for positive divisors. This calculator computes the modulo of any two numbers, including negative values and large integers, following the standard mathematical convention where the result has the same sign as the divisor.

Modular arithmetic, sometimes called clock arithmetic, is one of the most widely used concepts in computer science and cryptography. Every time you check whether a number is even or odd, you are using mod 2. Hash tables use modulo to map keys to array indices. The RSA encryption algorithm that secures internet communications relies entirely on modular exponentiation with large prime numbers. In everyday life, modular arithmetic governs clocks (hours mod 12), calendars (days mod 7 for weekdays), and cyclic patterns like rotating shifts or round-robin scheduling.

In programming, the modulo operator is essential for tasks such as wrapping array indices, implementing circular buffers, formatting output (adding a line break every n items), and validating identification numbers. Credit card validation uses the Luhn algorithm, which employs modulo 10 to detect single-digit errors and adjacent transposition errors. One subtlety to watch: different programming languages handle negative number modulo differently -- Python returns a result with the sign of the divisor, while C and Java return a result with the sign of the dividend. This calculator uses the mathematical convention.

Frequently Asked Questions

Is this free?

Yes, completely free with no signup required.

How accurate is it?

Uses standard formulas — accurate for estimation. Verify critical decisions with a professional.

Can I share results?

Yes, click Share Result to copy a URL with your inputs.

Works on mobile?

Yes, fully responsive on all devices.

Related Calculators