Introduction
The modulo operation finds the remainder left over after dividing one number by another. For example, 17 mod 5 equals 2 because 5 goes into 17 three times (5 × 3 = 15), leaving a remainder of 2. This simple but powerful concept shows up everywhere — from checking if a number is even or odd to programming clocks and calendars.
Our Modulo Calculator makes it easy to compute remainders instantly. Enter a dividend and a divisor to find the remainder, or leave any one field blank and the calculator will solve for the missing value. It supports positive numbers, negative numbers, and even decimals. Each result includes a step-by-step breakdown so you can see exactly how the answer is reached. The calculator also shows results for both the truncated division method (used in languages like C and JavaScript) and the floored division method (used in Python and Ruby), so you always know which convention applies to your situation.
How to use our Modulo Calculator
Enter any two of the three values — dividend, divisor, or remainder — and this calculator will find the missing value, show the quotient, and explain each step of the solution.
Dividend (a): Enter the number you want to divide. This is the starting number in the modulo operation. For example, if you want to solve 17 mod 5, type 17 here. Use the ± button to switch between positive and negative values.
Modulus / Divisor (b): Enter the number you are dividing by. This value cannot be zero. For example, in 17 mod 5, the divisor is 5. Use the ± button to toggle the sign if you need a negative divisor.
Remainder (r): Leave this field empty to calculate the remainder from the dividend and divisor. If you already know the remainder and want to find a missing dividend or divisor, enter the remainder here and leave one of the other fields blank.
Input Mode: Choose between Structured Form, where you type numbers into separate fields, or Natural Language, where you can type expressions like "17 mod 5," "remainder of 100 divided by 7," or "25 % 4" and the calculator will read and solve them automatically.
Results: The calculator displays the remainder under both the truncated convention (used in C, Java, and JavaScript) and the floored convention (used in Python and Ruby). For positive numbers, both give the same answer. A step-by-step breakdown shows exactly how the remainder is found, and a quick reference table lists common modulo operations for easy comparison.
What Is the Modulo Operation?
The modulo operation finds the remainder after you divide one number by another. When you divide 17 by 5, you get 3 with a remainder of 2. That remainder is the modulo result. We write it as 17 mod 5 = 2. It's one of the most basic operations in arithmetic, right alongside addition, subtraction, multiplication, and division.
How Modulo Works Step by Step
To find a mod b, follow these steps:
- Divide the dividend (a) by the divisor (b).
- Drop the decimal part to get the integer quotient (q).
- Multiply the quotient by the divisor: q × b.
- Subtract that product from the original dividend: r = a − (q × b).
For example, with 100 mod 7: divide 100 ÷ 7 = 14.28..., truncate to 14, multiply 14 × 7 = 98, then subtract 100 − 98 = 2. So 100 mod 7 = 2.
Truncated vs. Floored Remainder
When both numbers are positive, there is only one answer. But when negative numbers are involved, two common conventions exist:
- Truncated division — The remainder takes the same sign as the dividend. Languages like C, Java, and JavaScript use this method. For −17 mod 5, the result is −2.
- Floored division — The remainder takes the same sign as the divisor. Languages like Python and Ruby use this method. For −17 mod 5, the result is 3.
This calculator shows both results so you always know which one applies to your situation.
Common Uses of Modulo
The modulo operation shows up everywhere in daily life and math:
- Checking if a number is even or odd: If n mod 2 = 0, the number is even. If n mod 2 = 1, it's odd. You can verify divisibility for any factor — our Prime Factorization Calculator can help you find all the factors of a number.
- Clock arithmetic: A 24-hour clock wraps around using mod 12 or mod 24. For instance, 15:00 in 12-hour time is 15 mod 12 = 3 o'clock.
- Splitting items into groups: If you have 23 students and want groups of 5, then 23 mod 5 = 3 tells you 3 students will be left over.
- Finding divisibility: A number is divisible by another when the remainder is zero. For example, 100 mod 25 = 0 means 100 is perfectly divisible by 25. Related tools like the GCF Calculator and LCM Calculator also rely on divisibility concepts.
- Programming and computer science: Modulo is used for cycling through arrays, hashing, generating patterns, and controlling repeating sequences.
How to Use This Calculator
This modulo calculator can do more than just find the remainder. Enter any two of the three values — dividend (a), divisor (b), or remainder (r) — and it will solve for the missing one. If you leave the remainder blank and fill in the dividend and divisor, it calculates the remainder. If you leave the divisor blank, it finds a valid divisor. It also works with negative numbers and decimals, showing you both the truncated and floored results along with a full step-by-step breakdown of the math. For other fundamental arithmetic tasks, explore our Fraction Calculator, Percentage Calculator, or Exponent Calculator.