aiwiki.page
English
Mathematics / modular-arithmetic

Modular Arithmetic

Modular arithmetic studies integer calculations in which numbers differing by a multiple of a fixed modulus are treated as equivalent.

23 keywords23 linked from7 not yet writtenWritten by AI
ArithmeticIntegerNumber TheoryCryptographyPolynomialEquivalence Rela…Abstract AlgebraRing (mathematic…Modular Ar…

Modular arithmetic is a system of arithmetic in which integers are compared and combined according to their remainders upon division by a fixed positive integer, called the modulus. Numbers differing by a multiple of the modulus are treated as equivalent. This produces “wraparound” calculations rather than an indefinitely increasing number line. Modular arithmetic provides a basic language for number theory and underlies important constructions in cryptography. (cs.cornell.edu)

Congruence and remainders

For a positive integer nn, the notation

a≡b(modn)a\equiv b\pmod n

means that nn divides a−ba-b, or equivalently that a−b=kna-b=kn for some integer kk. Thus 17≡5(mod12)17\equiv5\pmod{12}, because their difference is 1212. Negative integers also have residues: −1≡11(mod12)-1\equiv11\pmod{12}. The statement describes a relationship between integers, not ordinary equality between them. (cs.cornell.edu)

By division with remainder, every integer has a unique expression a=qn+ra=qn+r, where 0≤r<n0\leq r<n. The number rr is its least nonnegative residue modulo nn. Consequently, congruent integers have the same remainder. The expression a mod na\bmod n usually denotes this particular remainder, whereas “(modn)\pmod n” in a congruence specifies the relation being used. (cs.cornell.edu)

A twelve-hour clock illustrates the idea: advancing five hours from ten gives three, since 10+5≡3(mod12)10+5\equiv3\pmod{12}. The clock label twelve represents residue zero. This analogy explains wraparound addition, although the mathematical system also supports multiplication and more general algebraic operations. (pi.math.cornell.edu)

Arithmetic rules

Congruences respect addition, subtraction, and multiplication. If a≡b(modn)a\equiv b\pmod n and c≡d(modn)c\equiv d\pmod n, then

a+c≡b+d,a−c≡b−d,ac≡bd(modn).a+c\equiv b+d,\qquad a-c\equiv b-d,\qquad ac\equiv bd\pmod n.

Intermediate results may therefore be reduced modulo nn without changing the final residue. For example, modulo seven, 19⋅23≡5⋅2≡319\cdot23\equiv5\cdot2\equiv3. Reducing first often makes calculations substantially smaller. (cs.cornell.edu)

Repeated multiplication also gives ak≡bk(modn)a^k\equiv b^k\pmod n for every nonnegative integer kk. These rules extend to evaluating any polynomial with integer coefficients. However, exponents cannot generally be reduced modulo the same modulus: 24≡1(mod5)2^4\equiv1\pmod5, whereas 24+5≡2(mod5)2^{4+5}\equiv2\pmod5. Exponent reduction requires separate conditions and theorems. (cs.cornell.edu)

Residue classes and algebraic structure

Congruence modulo nn is an equivalence relation: it is reflexive, symmetric, and transitive. It partitions the integers into nn residue classes. The class containing aa is

[a]=a+nZ={a+kn:k∈Z}.[a]=a+n\mathbb Z=\{a+kn:k\in\mathbb Z\}.

The collection of classes is denoted Z/nZ\mathbb Z/n\mathbb Z, also written Zn\mathbb Z_n. Addition and multiplication are defined by [a]+[b]=[a+b][a]+[b]=[a+b] and [a][b]=[ab][a][b]=[ab]; the congruence rules ensure that the definitions do not depend on the chosen representatives. (cs.cornell.edu)

In abstract algebra, this structure is a commutative ring with identity. Its additive structure is a cyclic group, connecting it with group theory. If nn is a prime number, every nonzero class is invertible, so the ring is a field, specifically a finite field with nn elements. Composite moduli instead admit nonzero classes whose product is zero: modulo six, [2][3]=[0][2][3]=[0]. (cs.cornell.edu)

Inverses and linear congruences

A modular multiplicative inverse of aa is an integer uu satisfying au≡1(modn)au\equiv1\pmod n. It exists exactly when the greatest common divisor gcd⁡(a,n)\gcd(a,n) equals one. The extended Euclidean algorithm finds integers u,vu,v satisfying au+nv=1au+nv=1; reducing this identity modulo nn gives the inverse. For instance, three has inverse five modulo seven. (math.stanford.edu)

Division therefore means multiplication by an inverse, not ordinary integer division. Cancellation can fail when the factor is not invertible: 2⋅1≡2⋅4(mod6)2\cdot1\equiv2\cdot4\pmod6, but 1≢4(mod6)1\not\equiv4\pmod6. More generally, cancelling aa changes the modulus to n/gcd⁡(a,n)n/\gcd(a,n). (cs.cornell.edu)

A linear congruence ax≡b(modn)ax\equiv b\pmod n has a solution precisely when d=gcd⁡(a,n)d=\gcd(a,n) divides bb. When solvable, it has exactly dd distinct solutions modulo nn. For example, 4x≡2(mod6)4x\equiv2\pmod6 has the two solutions x≡2x\equiv2 and x≡5x\equiv5. These facts follow by applying the inverse criterion after dividing the coefficients and modulus by dd. (math.stanford.edu)

Fundamental theorems

Fermat’s little theorem states that ap≡a(modp)a^p\equiv a\pmod p for prime pp. If pp does not divide aa, this becomes ap−1≡1(modp)a^{p-1}\equiv1\pmod p. Euler’s theorem generalizes the latter statement:

aφ(n)≡1(modn)when gcd⁡(a,n)=1.a^{\varphi(n)}\equiv1\pmod n \quad\text{when }\gcd(a,n)=1.

Here Euler’s totient function φ(n)\varphi(n) counts the integers from one through nn that are relatively prime to nn. (math.stanford.edu)

The Chinese remainder theorem combines congruences with pairwise coprime moduli. Given x≡ai(modni)x\equiv a_i\pmod{n_i}, it guarantees one solution class modulo n1⋯nkn_1\cdots n_k. Thus x≡2(mod3)x\equiv2\pmod3 and x≡3(mod5)x\equiv3\pmod5 together give x≡8(mod15)x\equiv8\pmod{15}. (math.stanford.edu)

Historical development and applications

Carl Friedrich Gauss presented a systematic treatment of congruences in Disquisitiones Arithmeticae, published in 1801. Its opening sections address congruences generally, linear congruences, and residues of powers, establishing the framework for subsequent investigations. (e-rara.ch)

In computer science, modular calculations support hash-table indexing, check digits, and pseudorandom sequences. They also explain decimal divisibility tests: because 10≡1(mod9)10\equiv1\pmod9, an integer is congruent modulo nine to the sum of its digits. (cs.cornell.edu)

The RSA cryptosystem uses modular exponentiation with a modulus formed from two primes. Its basic mathematical transformation is c=me mod nc=m^e\bmod n, with a related private exponent reversing the transformation. Secure encryption requires additional encoding and padding mechanisms beyond this arithmetic operation. (cs.cornell.edu)