Updated on April 21st, 2026

Modulo Calculator

Created By Jehan Wadia

a mod b = r
(a)
Invalid value
(b)
Divisor cannot be zero
(r)
Invalid value

Result
17 mod 5 = 2
Dividend (a) 17
Modulus / Divisor (b) 5
Integer Quotient (q) 3
Remainder (r) — Truncated 2
Remainder (r) — Floored 2
Truncated Division (C, Java, JavaScript): The remainder has the same sign as the dividend. r = a - b × trunc(a/b)
Floored Division (Python, Ruby): The remainder has the same sign as the divisor. r = a - b × floor(a/b)
For positive operands, both conventions give the same result.
Step-by-Step Breakdown
1Start with a = 17 and b = 5
2Divide: 17 ÷ 5 = 3.4
3Truncate toward zero: q = trunc(3.4) = 3
4Multiply: q × b = 3 × 5 = 15
5Subtract: r = a - (q × b) = 17 - 15 = 2
6Result: 17 mod 5 = 2 with quotient q = 3
Quick Reference: Common Modulo Operations
Expression Quotient (q) Remainder (r)
10 mod 331
25 mod 734
100 mod 1379
17 mod 532
-17 mod 5-3 / -4-2 / 3
17 mod -5-3 / -42 / -3
7.5 mod 2.530
10 mod 250

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:

  1. Divide the dividend (a) by the divisor (b).
  2. Drop the decimal part to get the integer quotient (q).
  3. Multiply the quotient by the divisor: q × b.
  4. 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.


Frequently Asked Questions

What does mod mean in math?

Mod (short for modulo) means finding the remainder after dividing one number by another. For example, 10 mod 3 = 1 because 3 goes into 10 three times (3 × 3 = 9) with 1 left over.

What happens if I divide by zero in the modulo calculator?

The calculator will show an error. You cannot divide by zero in any math operation, including modulo. The divisor (b) must always be a number other than zero.

Can I use decimals with this modulo calculator?

Yes. This calculator supports decimal numbers. For example, 7.5 mod 2.5 = 0 because 2.5 goes into 7.5 exactly 3 times with nothing left over.

What is the difference between mod and division?

Division tells you how many times one number fits into another. Modulo tells you what is left over after that division. For example, 17 ÷ 5 = 3.4, but 17 mod 5 = 2. The 2 is the remainder.

Why do I get two different remainders for negative numbers?

There are two common rules for handling negative numbers. The truncated method gives a remainder with the same sign as the dividend. The floored method gives a remainder with the same sign as the divisor. For example, −17 mod 5 gives −2 (truncated) or 3 (floored). Both are correct — it just depends on which rule you follow.

What does it mean when the remainder is 0?

A remainder of 0 means the dividend is perfectly divisible by the divisor. For example, 10 mod 5 = 0 because 5 goes into 10 exactly 2 times with nothing left over.

How do I find the divisor if I know the dividend and remainder?

Enter the dividend in the first field and the remainder in the third field. Leave the divisor (middle field) blank. The calculator will find a valid divisor for you and show the work.

How do I find the dividend if I know the divisor and remainder?

Enter the divisor in the middle field and the remainder in the third field. Leave the dividend (first field) blank. The calculator will find the smallest non-negative dividend that gives that remainder.

Is 0 mod any number always 0?

Yes. 0 mod b = 0 for any non-zero number b. Since 0 divided by anything is 0 with no remainder, the result is always 0.

What is the formula for the modulo operation?

The formula is r = a − b × q, where a is the dividend, b is the divisor, and q is the integer quotient from dividing a by b. For the truncated method, q = trunc(a ÷ b). For the floored method, q = floor(a ÷ b).

Can the remainder be bigger than the divisor?

No. The remainder is always smaller in absolute value than the divisor. If you get a remainder equal to or larger than the divisor, it means the division was not done correctly.

How does the natural language input work?

Switch to Natural Language mode and type your problem in plain words. You can type things like "17 mod 5," "remainder of 100 divided by 7," or "25 % 4." The calculator will read your input and solve it automatically.

What does the ± button do?

The ± button flips the sign of the number in that field. If the number is positive, it becomes negative. If it is negative, it becomes positive. This is a quick way to test modulo with negative values.

Is mod the same as the percent sign (%) in programming?

In most programming languages, the % symbol performs a modulo or remainder operation. In languages like C, Java, and JavaScript, it uses the truncated method. In Python, it uses the floored method. The math is the same idea — finding a remainder — but the sign rules may differ.


Related Calculators

Fraction Calculator

Visit Fraction Calculator