Finding the Remainder Left Over From Division
Modulo finds the remainder left over after dividing one number by another. Enter a dividend and a divisor, and this calculator returns the remainder — the same value you’d get from long division, on its own.
The Formula
where is the dividend and is the divisor, and rounds toward
zero — this calculator uses JavaScript’s native % operator, so for a negative dividend the
result takes the sign of the dividend (not the divisor), as explained below.
Worked Example
17 mod 5:
- remainder — since , and .
Key Factors to Consider
- Different programming languages and math conventions handle negative numbers differently.
This calculator uses the “sign of the dividend” convention common in most programming languages
(JavaScript, C, Java) — but Python’s
%operator and some math textbooks use a convention where the result always matches the sign of the divisor instead, which can give a different-looking answer for the same negative inputs. - The result of a mod n is always between 0 and n-1 (using the non-negative convention), which is exactly why modulo is used for “wrapping” behavior. This bounded-range property is what makes modulo the natural tool for anything cyclical — clock arithmetic, days of the week, array indexing that wraps around, and repeating patterns all rely on this same bounded wraparound behavior.
- Checking if a number is even or odd is just modulo 2. Any number mod 2 is either 0 (even) or 1 (odd) — this is one of the simplest and most common practical uses of modulo in everyday programming.
- Modulo is a foundational operation in cryptography, particularly with large prime numbers. Modular arithmetic (working with remainders under a fixed modulus) underlies widely-used encryption schemes like RSA — the same basic remainder concept this calculator computes scales up to numbers hundreds of digits long in real cryptographic applications.
Common Mistakes
- Assuming modulo always gives a non-negative result. This calculator’s “sign of the dividend” convention means a negative dividend produces a negative (or zero) remainder — confirm which convention you actually need before comparing results across tools.
- Confusing modulo with plain division. Modulo returns only the leftover remainder, not the quotient — 17 divided by 5 is 3.4, but 17 mod 5 is 2, a very different number used for a very different purpose.
- Forgetting that a modulus of 0 is undefined. Division by zero has no answer, and neither does a mod 0 — any calculator or program should treat this as an error, not silently return 0 or the dividend unchanged.
- Mixing up which number is the dividend and which is the divisor. a mod n is not the same as n mod a except in special cases — swapping the two order changes the result entirely, not just its sign.
Useful to Know
- Need the full quotient and remainder shown step by step, not just the remainder? Long Division Calculator walks through the entire long-division process.
- Working with two numbers’ shared factors or a common multiple instead of a remainder? Greatest Common Factor and Least Common Multiple Calculator finds the GCF and LCM.
- Curious whether a number itself is prime, or how it breaks down into factors? Prime Factorization Calculator shows the full prime factorization.