Calculate modulo operations (a mod b) with step-by-step explanations. Perfect for programmers, math students, and anyone working with remainder calculations.
Where a is the dividend and b is the divisor
The number being divided (can be negative)
The number to divide by (cannot be zero)
Basic positive modulo
Clock analogy (1 o'clock)
Multiple circles
Programming example
Large number modulo
Small divisor
The modulo operation finds the remainder after division of one number by another. It's denoted as a mod b or a % b in programming.
Remember: The mathematical definition ensures the result is always non-negative when the divisor is positive.
Array index wrapping: i % array.lengthEven/odd check: n % 2 == 0Circular buffer: (index + 1) % bufferSizeHash table indexing: hash % tableSizeModular arithmetic: (a + b) mod mCryptography: RSA encryptionNumber theory: GCD calculationsCongruence relations: a ≡ b (mod m)Clock arithmetic: (hour + n) % 12Day of week: day % 7Circular patterns: step % cycleRemainder calculationsIn modular arithmetic, numbers repeat after the modulus. For example, with modulus 12, values 0 and 12 are equivalent, as are 1 and 13. This equivalence is why modular math is foundational in scheduling, cryptography, and hashing. It compresses an unbounded integer line into a predictable cycle.
Example: suppose your app displays items in pages of 8 cards. If the global item index is 27, the in-page slot is. That means item 27 appears in slot 4 (zero-based index 3). Another example: if a recurring task runs every 14 days, checking quickly tells you whether you're on run day (remainder 0) without date-heavy logic.
The biggest pitfall is negative numbers. Some languages return negative remainders, others return non-negative modulo values. If you're building cross-language systems, normalize with when so results stay inside . This avoids off-by-one bugs in arrays, game loops, and encryption code.
For manual checks, always verify with . If remainder falls outside the expected range, either the quotient or sign handling is wrong. Practicing this verification step makes debugging modulo-heavy algorithms much faster.
Ask a 12-hour clock what happens one hour after 12 and it says 1, not 13. Ask a calendar what day lands 100 days after Tuesday and it quietly wraps around the week until it lands on Thursday.
That's modulo. Not advanced. Not exotic. Just the arithmetic of wraparound.
Once numbers start cycling instead of growing forever, ordinary division stops being the star of the show and remainders take over.
Take 17 divided by 5. You can make three full groups of 5, which uses 15. The leftover is 2.
So
In general,
Here is the integer quotient and is the remainder. Modulo is just the remainder part. That's it.
Which makes the day-of-week trick easy. If you label Tuesday as 2, then 100 days later is , which lands on Thursday.
Positive-number modulo is peaceful. Negative-number modulo is where programmers, mathematicians, and different programming languages start talking past each other.
Look at . One convention gives because you want the result to stay in the range to . Another gives because it keeps the sign behavior tied to truncated division.
Neither system is "fake." They answer slightly different questions. The important part is knowing which convention your tool or language uses before you trust the output.
Say you have 8 images in a carousel. You're on image 7. The user hits "next" twice. Where do you land? Index math says . Back to the beginning, smoothly.
Same trick shows up in:
That last one connects straight to the GCF and Euclid's algorithm. Modular arithmetic and divisibility are basically neighbors sharing the same fence.
Want the last digit of ? You could multiply 7 by itself 100 times. Or you could notice the last digits cycle:
The pattern length is 4. Since , the 100th power lands on the fourth step of the cycle, so the last digit is 1.
That's the real appeal of modulo. It shrinks huge problems down to a repeating pattern you can actually hold in your head.
For positive numbers, usually yes. With negative numbers, not always. Some systems define modulo to stay nonnegative. Others report a remainder that can be negative.
Because many languages use the operator for remainder-like behavior. But the exact negative-number convention still depends on the language, so the symbol alone doesn't tell the whole story.
When one number divides the other evenly. If , then is a divisor of . That's why mod is handy for testing divisibility.
Find GCF/GCD of two or more numbers using Euclidean algorithm and prime factorization methods with step-by-step explanations.
Perform long division with detailed step-by-step solutions. Learn the division algorithm with clear explanations.
Factor polynomials using GCF, difference of squares, and more with step-by-step solutions for algebra students.
Convert fractions to decimals with detailed long division steps. Supports proper, improper, and mixed fractions.