KiloAtlas
EN
EnglishBahasa IndonesiaTiếng Việt

Modulo Calculator

Find a nonnegative remainder for a signed integer and a positive integer modulus.

Remainder r

3
Floor quotient q
-4

Formula

q = floor(a/m); r = a − m×q; 0 ≤ r < m

Floor quotient q ≈ floor((-17)÷(5)) · Remainder r ≈ (-17)-(5)×(-4)

How to use

  1. Enter a signed integer a.
  2. Enter a positive integer modulus m.
  3. Read the remainder and floor quotient.

Examples

  • 17 mod 5 = 2; −17 mod 5 = 3.

Frequently asked questions

Can the dividend be negative?

Yes. −17 modulo 5 is 3 because −17 = 5×(−4)+3.

Why can programming languages disagree?

Some use a remainder with the dividend’s sign. This tool uses floor division and a positive modulus.

Can the modulus be zero?

No. It must be a positive integer.

Sources

Updated:

Related tools

Search conversion tools