---
slug: modulo-calculator
title: "Modulo Calculator"
category: math
updated: 2026-11-17
canonical: https://calcseed.com/c/math/modulo-calculator/
html: /c/math/modulo-calculator/
---

# Modulo Calculator

Calculate the remainder when one number is divided by another. Free and instant.

## Quick answer

**Quick answer:** with the default inputs (17, 5), the remainder is **2**. Change any input to update the result.

## Default calculation

Values computed by this calculator at exactly the default inputs listed below.

### Inputs (defaults)

| Input | Value | Unit |
| --- | --- | --- |
| Dividend | 17 |  |
| Divisor | 5 |  |

### Outputs at these defaults

| Output | Value | Unit |
| --- | --- | --- |
| Remainder | 2 |  |

## Formula

```text
a mod b = a − b × &lfloor;a ÷ b&rfloor;
```

## Inputs

| Variable | Type | Unit | Default |
| --- | --- | --- | --- |
| Dividend | number |  | 17 |
| Divisor | number |  | 5 |

## Outputs

| Result | Format |
| --- | --- |
| Remainder | primary |
| Remainder | number |

## How it works

### What this calculator does

Enter a dividend a and a divisor b, and the calculator returns the remainder after whole-number division. At the defaults, 17 mod 5 = 2, because three fives fit into 17 (15) and 2 is left over. The result always lands between 0 and b − 1, even for negative inputs, which makes it safe to feed into further calculations.

### How the modulo operation works

Modulo answers the question of what is left after you strip out as many whole copies of b as possible. Divide a by b, throw away the decimal part, multiply back, and subtract. Formally the operation uses the floor function, which rounds a quotient down to the nearest whole number before the subtraction.

#### Worked example: 17 mod 5

Compute the floor of 17 ÷ 5 = 3.4, which is 3. Multiply back: 5 × 3 = 15. Subtract: 17 − 15 = 2. So 17 mod 5 = 2, matching the calculator. The check runs the other direction too: 5 × 3 + 2 = 17, meaning quotient 3 and remainder 2 reconstruct the original number exactly, which is the definition of division with remainder.

### Remainders at a glance

| a | b | a mod b | Reading |
| --- | --- | --- | --- |
| 17 | 5 | 2 | Three 5s fit, 2 left over |
| 10 | 3 | 1 | Ten is one past a multiple of 3 |
| 100 | 7 | 2 | Fourteen 7s fit, 2 left over |
| 7 | 10 | 7 | Nothing fits, so a itself remains |
| 20 | 5 | 0 | Divides exactly, no remainder |
| −7 | 5 | 3 | Euclidean remainder is non-negative |

Two rows carry most of the lessons. When a is smaller than b, as in 7 mod 10, nothing can be stripped away and the remainder is a itself. When b divides a exactly, as in 20 mod 5, the remainder is 0 — and that zero is the standard test for divisibility, evenness (n mod 2 = 0) and whether a schedule repeats.

### Negative numbers

Negative dividends are where conventions diverge. Programming languages disagree: JavaScript&rsquo;s % operator returns −7 % 5 = −2, keeping the dividend&rsquo;s sign, while mathematicians prefer the Euclidean remainder, which is always non-negative. This calculator follows the Euclidean convention: −7 mod 5 = 3, because −10 is the largest multiple of 5 that is &le; −7, leaving a gap of 3. Both answers differ by exactly one divisor, so converting between conventions is a one-line adjustment: if the remainder comes out negative, add b.

### Why modulo shows up everywhere

#### Clocks and calendars

Modulo is the arithmetic of numbers wrapping around. A 12-hour clock computes 14 o&rsquo;clock as 14 mod 12 = 2, and a 24-hour clock never shows 25. Days of the week run mod 7: if today is Monday, 100 days from now lands 100 mod 7 = 2 weekdays past Monday, a Wednesday. Every repeating cycle — shift schedules, billing periods, recurring alarms — reduces its scheduling questions to a modulo calculation.

#### Dividing into groups

Modulo also solves the packing problem of how many containers a count needs. Seventeen items in boxes of 5 fill 3 boxes with 2 left over, so you need 4 boxes — the ceiling of 17 ÷ 5. The remainder tells you instantly: a nonzero remainder means add one to the quotient, and 17 mod 5 = 2 is nonzero, so the answer is 3 + 1 = 4. The same logic sets up team sizes, batch counts, seating rounds and shipping cartons.

#### Computing and cryptography

Computing leans on the same operation at enormous scale. Hash tables assign a record to bucket n mod (number of buckets), random number generators cycle through a fixed modulus, checksums detect transmission errors with modular arithmetic, and cryptography builds security on modular exponentiation. The humble remainder is doing the work in all of them, and the same test appears in schoolwork: a number is divisible by 9 exactly when its digit sum is 0 mod 9, and 17&rsquo;s digit sum 1 + 7 = 8 matches 17 mod 9 = 8.

### Common mistakes

- Reversing the operands: 5 mod 17 = 5, while 17 mod 5 = 2, and the two are unrelated
- Confusing the remainder with the quotient; 17 ÷ 5 has quotient 3 and remainder 2
- Carrying a negative remainder from a programming % operator without adding b to normalize it
- Using modulo on decimals; the operation is defined for whole numbers
- Assuming a remainder of 0 means something went wrong; it means the division is exact

The operand reversal is the most common slip in homework, so read the expression aloud: a mod b is the remainder when a is divided by b, in that order. A quick sanity check catches both reversal and sign errors — the result must satisfy 0 &le; remainder < b, so any answer of 5 from a mod-5 problem is impossible.

## FAQ

### How do I calculate 17 mod 5?

Take the whole-number quotient 3, multiply back to 15, and subtract: 17 − 15 = 2. The remainder is 2, and 5 × 3 + 2 = 17 confirms it.

### What is the result when a is smaller than b?

The remainder is a itself. Since 7 ÷ 10 goes 0 times, 7 mod 10 = 7, and nothing is stripped away.

### Does modulo work with negative numbers?

Yes, but conventions differ. This calculator returns the Euclidean remainder, always between 0 and b − 1: −7 mod 5 = 3. JavaScript&rsquo;s % would give −2, and adding 5 converts between the two.

### How do I check if a number is even with modulo?

Compute n mod 2. A result of 0 means even; 1 means odd. The same pattern checks divisibility by anything: 100 mod 7 = 2, so 7 does not divide 100.

### How does a 12-hour clock use modulo?

It wraps hours at 12: hour 14 reads as 14 mod 12 = 2 o&rsquo;clock, and hour 24 wraps to midnight. Any cyclic count of 12 items works the same way.

### What day of the week is 100 days after Monday?

100 mod 7 = 2, so the day lands 2 weekdays past Monday: Wednesday. The divisor 7 matches the length of the weekly cycle.

### What does a remainder of 0 mean?

The dividend divides the divisor exactly. 20 mod 5 = 0 says 5 is a factor of 20, which is the standard divisibility test underlying the factor and prime checkers.

### Why do different languages give different negative remainders?

Some keep the dividend&rsquo;s sign (JavaScript, C) and others the divisor&rsquo;s (Python, which returns 3 for −7 % 5). The mathematical Euclidean convention always picks the non-negative remainder, as this calculator does.

### How is modulo used in hashing?

A record&rsquo;s key is divided by the number of buckets and the remainder selects the bucket, keeping indices within range. Ten buckets map any key to a slot from 0 to 9 through key mod 10.

## Method and sources

Methodology: Results follow exact mathematical definitions; the arithmetic is deterministic and can be verified by hand from the steps shown.

Last updated: 2026-11-17.
- Modulo (Euclidean remainder): a mod b = a - b * floor(a / b).
