download.fan

Modulo Calculator

Calculate a mod n for whole or decimal numbers of any size, with the quotient and remainder. Shows the math (floored) and programming (truncated) results.

17 mod 5
2
Quotient (floored)
3
Remainder (truncated, like % in C or JavaScript)
2
Check
3 × 5 + 2 = 17

Modulo: the remainder after division

a mod n is what's left after dividing a by n as many whole times as possible: 17 mod 5 = 2, because 17 = 3 × 5 + 2. With negative numbers there are two conventions. Mathematics (and Python) use the floored result, which takes the sign of the divisor: −17 mod 5 = 3. C, Java and JavaScript's % operator truncate, giving −2. The calculator shows both, and handles whole numbers of any length exactly.

How to use it

  1. 1

    Enter the dividend

    The number being divided (a).

  2. 2

    Enter the divisor

    The modulus (n).

  3. 3

    Read the result

    a mod n, the quotient and both remainders.

Frequently asked questions

What is 10 mod 3?

1, because 10 = 3 × 3 + 1.

Why do calculators disagree on negative numbers?

Some use floored division (result has the divisor's sign) and some truncated division (result has the dividend's sign).

What is modulo used for?

Clock arithmetic, checking even and odd numbers, cycling through lists, check digits and cryptography.

Is anything stored?

No. The calculation runs in your browser.

Math calculators

Related tools