Remainder

Arithmetic

The remainder is the amount left over after dividing one integer by another when the division is not exact.

Formula

a = b \times q + r, \text{ where } 0 \le r < b
Visualization

Definition

The remainder is what is left over after you divide as evenly as possible; it is always smaller than the number you divided by. By the Division Algorithm, for integers $a$ and $b$ ($b > 0$), there exist unique integers $q$ (quotient) and $r$ (remainder) such that $a = bq + r$ and $0 \le r < b$; the remainder is denoted $a \bmod b$, and if $r = 0$ then $b \mid a$. This defines an equivalence relation: $a$ is congruent to $b$ mod $n$ (written $a \equiv b \pmod n$) if $n \mid (a - b)$, and congruence classes form the ring $\mathbb{Z}/n\mathbb{Z}$.

Example

$17 / 5 = 3$ remainder $2$: five goes into $17$ three times ($= 15$), and $17 - 15 = 2$ is left over. $23 \bmod 7 = 2$ (since $23 = 7 \times 3 + 2$), and $56 \bmod 8 = 0$, confirming $8$ divides $56$. RSA encryption relies on this idea through modular exponentiation, $c = m^e \bmod n$, with decryption via $d = c^d \bmod n$ where $ed \equiv 1 \pmod{\phi(n)}$, security resting on the difficulty of factoring $n = pq$.

Key Insight

If the remainder is $0$, the division is exact and the divisor is a factor of the dividend; if not, the divisor does not divide the dividend evenly. The remainder (modulo operation) is the foundation of clock arithmetic: hours are computed mod $12$, so $10$ hours after $5$ o'clock is $(5 + 10) \bmod 12 = 3$ o'clock. The Chinese Remainder Theorem extends this, stating that if $\gcd(m, n) = 1$, the system $x \equiv a \pmod m$, $x \equiv b \pmod n$ has a unique solution mod $mn$, and modular arithmetic more broadly underpins modern cryptography, hash functions, error-correcting codes, and pseudorandom number generators.