Modulo Calculator
Find the remainder when one integer is divided by another. Great for math homework, coding checks, and quick number patterns.
What Is a Mod (Modulo) Calculation?
A mod operation tells you the remainder after division. When you calculate a mod b, you are asking:
“If I divide a by b, what number is left over?”
Example: 29 mod 5 = 4 because 29 = 5 × 5 + 4.
This simple operation is surprisingly powerful and appears all over mathematics, computer science, scheduling, and cryptography.
How to Use This Mod Calculator
- Enter the first integer as the dividend (a).
- Enter the second integer as the divisor (b).
- Choose a mode:
- Math modulo: remainder is always zero or positive.
- JavaScript remainder: follows the JavaScript
%operator.
- Click Calculate to see the result and the equation check.
The calculator also shows both styles so you can compare them quickly, especially when negative values are involved.
Modulo vs. Remainder (Why People Get Confused)
When numbers are positive, they usually match
For positive integers, modulo and remainder often give the same result.
Example: 17 mod 3 = 2, and 17 % 3 is also 2.
Negative numbers are where behavior changes
Consider -13 and 5:
- Math modulo:
-13 mod 5 = 2(kept in the range 0 to 4) - JavaScript remainder:
-13 % 5 = -3
Neither is “wrong”; they are different definitions used in different contexts. If you are working with cycles (hours, days, array wrapping), non-negative modulo is usually easier to reason about.
Practical Uses of Modulo
1) Even/odd checks
A number is even if n mod 2 = 0, odd otherwise.
2) Time and clock arithmetic
Clocks wrap around every 12 or 24 hours.
If it is 22:00 now, then 5 hours later is (22 + 5) mod 24 = 3.
3) Circular indexing
In programming, modulo helps rotate through arrays, playlists, UI tabs, or game turns:
nextIndex = (currentIndex + 1) mod length.
4) Hashing and bucketing
Hash tables and partition systems often use modulo to map large values into fixed-size bucket ranges.
5) Cryptography fundamentals
Many encryption systems use modular arithmetic because it creates stable, repeatable behavior over finite sets of integers.
Worked Examples
- 45 mod 7:
45 = 7 × 6 + 3so result is 3. - 100 mod 10: divides evenly, so result is 0.
- 73 mod 12:
12 × 6 = 72, remainder is 1. - -8 mod 3 (math modulo): result is 1.
Common Mistakes to Avoid
- Using 0 as divisor — modulo by zero is undefined.
- Assuming all languages define modulo exactly the same way with negative numbers.
- Forgetting that modulo is about the remainder, not the decimal quotient.
- Mixing “remainder” and “modulo” terminology without specifying which definition you need.
Quick FAQ
Can I use negative divisors?
Yes. This calculator accepts them. In math mode it uses the absolute value of the modulus to keep the result non-negative.
Do I need integers?
For classical modular arithmetic, yes. This calculator is built for integer input.
Why show both answers?
Because coding environments and textbooks may use different conventions. Seeing both helps prevent bugs and confusion.
Final Thought
Modulo is one of those tiny tools that unlocks a huge amount of practical logic. Once you get comfortable with it, many patterns in math and programming become much easier to spot.