Modulo Operation

The modulo operation finds the remainder when one integer is divided by another, useful when tracking cycles and repetition patterns.

amodn=anana \bmod n = a - n\left\lfloor \frac{a}{n} \right\rfloor

Solve a problem with Modulo Operation

Type the problem. The solver will use Modulo Operation where Modulo Operation is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Modulo Operation takes
aa
nn
Modulo Operation
SymbolMeaning
aaThe dividend—the number being divided. It can be positive, negative, or zero; if misread as the divisor, you'll get the reciprocal result.
nnThe divisor—the number you're dividing by. It must be non-zero to avoid undefined behavior; if you confuse it with the dividend, you'll divide the wrong way.

When to use it

Use modulo when you need to find the remainder after division, or when working with repeating patterns and cycles.

Level

Usually taught in: Pre-Algebra

Worked examples

1. Find the remainder using the modulo formula

Problem

Calculate 23mod623 \bmod 6.
  1. 236=3.83=3\lfloor \frac{23}{6} \rfloor = \lfloor 3.8\overline{3} \rfloor = 3

    Divide the dividend by the divisor: 23÷6=3.8323 ÷ 6 = 3.8\overline{3}. The floor function rounds down to 3.

  2. 63=186 \cdot 3 = 18

    Multiply the divisor by the floor result to find the largest multiple of 6 that fits into 23.

  3. 2318=523 - 18 = 5

    Subtract this multiple from the original number to get the remainder.

Answer: 23mod6=523 \bmod 6 = 5

This example shows the core formula in action with a straightforward case. We find how many complete groups of 6 fit into 23 (which is 3 groups), then see what is left over (5). Knowing both the quotient (3) and remainder (5) lets us write 23=63+523 = 6 \cdot 3 + 5.

2. Use modulo with a negative dividend

Problem

Calculate 13mod5-13 \bmod 5 using the formula.
  1. 135=2.6=3\lfloor \frac{-13}{5} \rfloor = \lfloor -2.6 \rfloor = -3

    Divide: 13÷5=2.6-13 ÷ 5 = -2.6. The floor function rounds down to the nearest integer, which for negative numbers means going more negative: 3-3, not 2-2.

  2. 5(3)=155 \cdot (-3) = -15

    Multiply the divisor by this floor result.

  3. 13(15)=13+15=2-13 - (-15) = -13 + 15 = 2

    Subtract the multiple from the dividend. Subtracting a negative flips to addition.

Answer: 13mod5=2-13 \bmod 5 = 2

This example demonstrates that modulo with negative dividends requires careful use of the floor function. Many students round 2.6-2.6 to 2-2 (toward zero) rather than 3-3 (toward negative infinity), which leads to the wrong answer. Using the formula ensures the remainder always has the same sign as the divisor when the divisor is positive.

3. Apply modulo to a real-world timing scenario

Problem

A climate lab records temperature data every 8 hours, with the first reading at midnight. After 103 hours have passed, at what position in the current 8-hour measurement cycle is the lab?
  1. 1038=12.875=12\lfloor \frac{103}{8} \rfloor = \lfloor 12.875 \rfloor = 12

    Divide 103 by 8 to find how many complete 8-hour cycles have passed. The floor of 12.87512.875 is 12.

  2. 812=968 \cdot 12 = 96

    Multiply to find the total hours accounted for in those 12 complete cycles.

  3. 10396=7103 - 96 = 7

    Subtract the accounted-for hours from the total elapsed time to find how many hours into the current cycle we are.

Answer: 103mod8=7103 \bmod 8 = 7

In this real-world context, the modulo result tells us the lab is 7 hours into its current 8-hour measurement cycle. This is why modulo is so powerful: it reduces any large number down to a manageable position within a repeating cycle. Scientists, programmers, and engineers use this principle constantly.

Common mistakes

Where Modulo Operation usually goes wrong
Answer came out wrong
Writing the quotient instead of the remainder. For 23mod623 \bmod 6, answering 3.
Complete the full formula anana - n\lfloor \frac{a}{n} \rfloor to extract the remainder: 2363=523 - 6 \cdot 3 = 5.
Rounding the quotient toward zero instead of using the floor function. For 13mod5-13 \bmod 5, rounding 2.6-2.6 to 2-2 and getting 135(2)=3-13 - 5(-2) = -3 as the final answer.
Apply floor correctly: 2.6=3\lfloor -2.6 \rfloor = -3, then 135(3)=2-13 - 5(-3) = 2.
Reporting the decimal result of division as the answer. For 47mod647 \bmod 6, writing 7.837.8\overline{3} instead of simplifying to the remainder.
Use the full formula: 476=7\lfloor \frac{47}{6} \rfloor = 7, then 4767=547 - 6 \cdot 7 = 5, so 47mod6=547 \bmod 6 = 5.
The mistakeWhy it is wrongThe fix
Writing the quotient instead of the remainder. For 23mod623 \bmod 6, answering 3.The modulo operation returns the remainder, not how many times the divisor divides into the dividend.Complete the full formula anana - n\lfloor \frac{a}{n} \rfloor to extract the remainder: 2363=523 - 6 \cdot 3 = 5.
Rounding the quotient toward zero instead of using the floor function. For 13mod5-13 \bmod 5, rounding 2.6-2.6 to 2-2 and getting 135(2)=3-13 - 5(-2) = -3 as the final answer.The floor function always rounds toward negative infinity (down on a number line), not toward zero. For negative quotients, this means going more negative.Apply floor correctly: 2.6=3\lfloor -2.6 \rfloor = -3, then 135(3)=2-13 - 5(-3) = 2.
Reporting the decimal result of division as the answer. For 47mod647 \bmod 6, writing 7.837.8\overline{3} instead of simplifying to the remainder.Modulo requires the complete formula to yield an integer remainder; just dividing gives a fraction or decimal that is not the modulo value.Use the full formula: 476=7\lfloor \frac{47}{6} \rfloor = 7, then 4767=547 - 6 \cdot 7 = 5, so 47mod6=547 \bmod 6 = 5.

Tips and when to use something else

  • When the dividend divides evenly by the divisor, the modulo result is 0. For example, 20mod5=020 \bmod 5 = 0 because 20=54+020 = 5 \cdot 4 + 0.
  • Use modulo with divisor 2 to test if a number is even or odd: if nmod2=0n \bmod 2 = 0, the number is even; if nmod2=1n \bmod 2 = 1, it is odd.
  • To understand modulo deeply, first master Long Division—modulo is just a compact notation for the remainder you find there.
  • When working with negative dividends, remember the floor function rounds toward negative infinity, which can produce results that feel counterintuitive if you are used to rounding toward zero.

Frequently asked questions

What is the difference between division and modulo?
Division tells you the quotient (how many times the divisor goes into the dividend), while modulo tells you the remainder (what is left over). For 17÷5=3.417 ÷ 5 = 3.4, the quotient is 3 and the remainder is 2, so 17mod5=217 \bmod 5 = 2. Any division can be written as a=bq+ra = b \cdot q + r, where qq is the quotient and rr is the modulo result.
Why does 30 mod 5 equal 0?
Because 5 divides evenly into 30 with no remainder: 30=56+030 = 5 \cdot 6 + 0. The modulo operation returns the remainder, which is 0 when there is nothing left over. Any time the dividend is a multiple of the divisor, the modulo result is 0.
How does modulo work with negative numbers?
Using the formula amodn=anana \bmod n = a - n\lfloor \frac{a}{n} \rfloor, negative dividends are handled by applying the floor function carefully. The floor always rounds toward negative infinity, not toward zero. So 13mod5=2-13 \bmod 5 = 2, not 3-3, because the formula ensures the result has the same sign as the divisor when the divisor is positive.
Why do programmers and scientists use modulo?
Modulo is essential for cycling through patterns—days of the week, clock positions, data wrapping, and scheduling tasks all rely on it. In cryptography it protects data, and in computer graphics it handles repeated textures. Anywhere you need to find a remainder or map a large number into a small repeating range, modulo is the tool.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18