Modulo Calculator
Calculate the remainder of division (modulo operation). Supports positive and negative numbers and shows the full division breakdown.
Did this tool work for you?
How to use this calculator
The modulo operation returns the remainder when a is divided by m.
- 1
Enter the dividend (number being divided).
- 2
Enter the modulus (divisor).
- 3
The result is the remainder after floor division.
- 4
Note: for negative numbers, mathematical modulo differs from the % operator in most languages.
Frequently asked questions
What is modulo used for in programming?
Checking even/odd (n % 2 === 0), wrapping array indices (index % length), cycling through values (counter % 7 for day of week), and hashing (key % table_size). It is one of the most frequently used operations in software development.
Why does -7 mod 3 differ from (-7) % 3 in JavaScript?
Mathematical modulo always returns a non-negative result when the modulus is positive: -7 mod 3 = 2 (because -7 = 3 × (-3) + 2). JavaScript's % operator follows the sign of the dividend: (-7) % 3 = -1. Python uses mathematical modulo; C, Java, and JS use truncating division.
What is modular arithmetic?
Modular arithmetic ("clock arithmetic") wraps numbers around a modulus. On a 12-hour clock, 10 + 5 = 3 (not 15), because 15 mod 12 = 3. It is foundational in cryptography (RSA, Diffie-Hellman), hashing, and cyclic data structures.
What is the difference between remainder and modulo?
They differ only for negative numbers. For positive inputs, they are identical. Remainder follows the sign of the dividend; modulo always matches the sign of the divisor. This calculator shows the true mathematical modulo.
The modulo operation explained
Modulo in everyday life
Clocks (12-hour), days of the week (7), months (12), and military time (24-hour) all use modular arithmetic. To find what day of the week a date falls on, compute the day number mod 7. Calendar algorithms rely heavily on modular arithmetic.
Modulo in cryptography
RSA encryption uses modular exponentiation: message^e mod n. The security relies on the difficulty of computing discrete logarithms modulo large primes. Diffie-Hellman key exchange, used in every HTTPS connection, is also built on modular arithmetic.
Modulo and hashing
Hash tables use index = hash(key) % table_size to map arbitrary keys to array indices. A good hash function distributes keys uniformly, minimizing collisions. The modulo operation ensures the index stays within the array bounds regardless of key value.
Learn more from an authoritative source:
WikipediaRectangle Calculator
Calculate area, perimeter, diagonal, and aspect ratio of a rectangle or square.
Mean, Median & Mode Calculator
Calculate mean, median, mode, range, and variance for a set of numbers. Enter up to 20 values.
Number Sequence Calculator
Identify and continue arithmetic and geometric sequences. Find the nth term and sum of the first n terms.
Roman Numerals Converter
Convert between Roman numerals and Arabic (standard) numbers. Handles values from 1 to 3,999.
Percentage Change Calculator
Calculate percentage increase or decrease between two values. Also computes percentage difference and what value X% of a number is.
Fibonacci Calculator
Generate the Fibonacci sequence up to any term and check if a number belongs to the sequence.
Results are estimates for informational purposes only and do not constitute professional financial, medical, legal, or technical advice. Read full disclaimer →