Quick answer
The modulo operation gives the remainder after division. The floored version is a mod n = a − n × ⌊a ÷ n⌋ and the truncated version a % n = a − n × trunc(a ÷ n). 17 mod 5 = 2.
Enter a dividend and divisor. The calculator returns the floored modulo and the truncated remainder.
Related tools: Fraction Calculator: Add, subtract, multiply and divide fractions with simplified and mixed-number results. Ratio Calculator: Simplify a ratio of two whole numbers. Average Calculator: Arithmetic mean, sum, count, minimum and maximum of a list of numbers.
How to use the Modulo Calculator
- Enter dividend (a whole number).
- Enter divisor (a whole number).
- Press Calculate to see the result, and use Reset to start again.
| Input | What to enter | Allowed values |
|---|---|---|
| Dividend | A whole number | — |
| Divisor | A whole number | — |
Formula and method
Formula
a mod n = a − n × ⌊a ÷ n⌋ (floored); a % n = a − n × trunc(a ÷ n) (truncated)
IEEE-754 double precision; shown to at most 6 decimal places.
Floored modulo always has the sign of the divisor; truncated remainder has the sign of the dividend.
Worked examples
These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.
Example 1
Inputs: Dividend = 17; Divisor = 5.
| Result | Value |
|---|---|
| a mod n | 2 |
| Truncated remainder | 2 |
Example 2
Inputs: Dividend = 7; Divisor = -3.
| Result | Value |
|---|---|
| a mod n | -2 |
| Truncated remainder | 1 |
The first line is the headline result (a mod n). Below it the modulo Calculator lists truncated remainder, which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.
Floored versus truncated
They agree for positive numbers, but differ with negatives: −7 mod 3 is 2 (floored, as in Python and mathematics) while −7 % 3 is −1 (truncated, as in C and JavaScript).
Uses
Clock arithmetic (15 hours + 10 = 1 o'clock: 25 mod 12), checking even or odd (n mod 2), cycling through array indexes and hash functions. The divisor cannot be zero.
How the result changes with dividend
Holding every other input at the first worked example, this table changes only dividend. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.
| Dividend | a mod n | Truncated remainder |
|---|---|---|
| 9 | 4 | 4 |
| 17 | 2 | 2 |
| 34 | 4 | 4 |
| 68 | 3 | 3 |
What happens with invalid input
These messages are produced by the calculator itself, so you know what to fix.
- Divisor: entering "0" shows "Divisor must not be 0." beside that field and no result.
Choosing between the Modulo Calculator and similar calculators
Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.
| Calculator | You enter | It returns |
|---|---|---|
| [Fraction Calculator](/math/fraction-calculator/) | numerator 1, denominator 1 and operation | Result |
| [Ratio Calculator](/math/ratio-calculator/) | first number and second number | Simplified ratio |
| [Average Calculator](/math/average-calculator/) | numbers | Average (mean) |
| [Long Division Calculator](/math/long-division-calculator/) | dividend and divisor | Quotient |
| [Percent Off Calculator](/math/percent-off-calculator/) | original price and discount | Sale price |
Background: rounding and basic arithmetic
Rounding to a place looks at the digit just to its right: 0 to 4 rounds down and 5 to 9 rounds up (the half-up convention, so 2.5 becomes 3). Rounding 838.274 gives 800 to the nearest hundred, 840 to the nearest ten and 838 to the nearest one.
Some systems use banker's rounding (half to even), which sends 2.5 to 2 and 3.5 to 4; check which convention your task requires, and round only at the end of a multi-step calculation.
Assumptions and limitations
- Divisor ≠ 0
If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for divisor to confirm this.
Frequently asked questions
What is 17 mod 5?
17 = 3 × 5 + 2, so 17 mod 5 = 2.
What is −7 mod 3?
−7 mod 3 is 2 in the floored convention (−7 = −3 × 3 + 2), while the truncated remainder is −1.
How do I test for divisibility?
A remainder of 0 means divisible.
What does the Modulo Calculator calculate?
Remainder of a division, with floored and truncated conventions. It returns a mod n and Truncated remainder.
What formula does the Modulo Calculator use?
a mod n = a − n × ⌊a ÷ n⌋ (floored); a % n = a − n × trunc(a ÷ n) (truncated). Floored modulo always has the sign of the divisor; truncated remainder has the sign of the dividend.
What do I need to enter in the modulo Calculator?
You enter Dividend and Divisor.
How is the result rounded or limited?
IEEE-754 double precision; shown to at most 6 decimal places. Divisor ≠ 0.
What is an example of a modulo result?
With dividend 17 and divisor 5, the a mod n is 2.
Related calculators
- Fraction Calculator — Add, subtract, multiply and divide fractions with simplified and mixed-number results.
- Ratio Calculator — Simplify a ratio of two whole numbers.
- Average Calculator — Arithmetic mean, sum, count, minimum and maximum of a list of numbers.
- Long Division Calculator — Divide whole numbers to a chosen number of decimal places.
- Percent Off Calculator — Find the sale price and savings after a percentage discount.
- Rounding Calculator — Round a number to decimal places, with up, down or nearest modes.
Sources
- OpenStax, Algebra and Trigonometry 2e (Rice University): exponents, radicals, logarithms and inverse trigonometric functions
Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.