# Modulo Calculator

> Remainder of a mod n with quotient and check, using mathematical or truncated conventions for negatives.

Page: https://freecalculator.tech/tools/modulo-calculator
Last reviewed: 2026-11-03

## Formula

a = n × q + r. Floored: q = ⌊a ÷ n⌋, so r has the sign of n. Truncated: q = trunc(a ÷ n), so r has the sign of a.

- Source: Wolfram MathWorld, Mod.
- Both conventions agree when a and n are both positive.
- a = n × q + r. Floored: q = ⌊a ÷ n⌋, so r has the sign of n. Truncated: q = trunc(a ÷ n), so r has the sign of a.
- Inputs used: Dividend a (whole number), Divisor n (whole number, not 0), Convention for negatives.

## Inputs

- Dividend a (whole number)
- Divisor n (whole number, not 0)
- Convention for negatives

## Worked example: 17 mod 5

17 = 5 × 3 + 2, so the remainder is 2.
1. ⌊17 ÷ 5⌋ = 3.
2. 17 − 5 × 3 = 2.

## Common questions

### Why is −7 mod 3 sometimes 2 and sometimes −1?

Mathematical (floored) modulo gives 2; truncated remainder, used by C and JavaScript %, gives −1. Choose the convention you need.

### Can I use decimals?

No. This calculator is limited to whole numbers to keep results exact.

### What is modulo used for?

Clock arithmetic, checking divisibility, cyclic indexes, hashing and checksums.

### How do I use the Modulo Calculator?

Enter the required values for Dividend a (whole number), Divisor n (whole number, not 0), Convention for negatives. The calculator applies the formula on this page and shows the main result with any supporting breakdown so you can check the arithmetic.

### What formula does the Modulo Calculator use?

a = n × q + r. Floored: q = ⌊a ÷ n⌋, so r has the sign of n. Truncated: q = trunc(a ÷ n), so r has the sign of a. The visible formula section above lists the calculation path and the edge cases the page handles, so the result can be checked without relying on the form alone.

### Can the Modulo Calculator be used for exact decisions?

Use it as a calculation aid, not as a substitute for checking the underlying rule, contract, policy, or professional advice that applies to your situation. When a result depends on local rules, personal details, prices, or dates, enter those values yourself and confirm them before acting.

## Limitations and assumptions

- Whole numbers within JavaScript's safe-integer range.
- Not modular inverse or modular exponentiation.
- Exact mathematical relationships, rounded for display. Check units and rounding before using a result in graded, engineering or financial work.
- The result depends on the values you enter for this modulo calculator; it does not supply missing rates, rules, prices, dates, or assumptions for you.

## Sources

- Wolfram MathWorld — https://mathworld.wolfram.com/Mod.html

## Cite this page

- APA: Free Calculator. (2026, November 3). Modulo Calculator. https://freecalculator.tech/tools/modulo-calculator
- MLA: "Modulo Calculator." Free Calculator, 3 Nov. 2026, https://freecalculator.tech/tools/modulo-calculator.
- Link: Modulo Calculator — Free Calculator, https://freecalculator.tech/tools/modulo-calculator
