Is Modulo Multiplication and Addition Associative, Distributive, and Commutative?

Find the is modulo multiplication and addition associative, distributive, and commutative? with clear results and the method shown.

Quick Facts

Associativity
(a+b)+c ≡ a+(b+c) (mod n)
Holds for every integer a, b, c and every modulus n ≥ 1 — grouping never changes the reduced result.
Commutativity
a+b ≡ b+a and a×b ≡ b×a (mod n)
Order never matters for modular addition or multiplication.
Distributivity
a×(b+c) ≡ a×b + a×c (mod n)
Multiplication distributes over addition mod n exactly as it does over the plain integers.
True modulo
mod(x, n) = ((x % n) + n) % n
Keeps the reduced value in the range 0 to n−1, even when x is negative.

Your Results

Calculated
Addition associative?
-
(a+b)+c vs a+(b+c), mod n
Multiplication associative?
-
(a×b)×c vs a×(b×c), mod n
Multiplication distributes?
-
a×(b+c) vs a×b + a×c, mod n
Addition & multiplication commutative?
-
a+b vs b+a, and a×b vs b×a, mod n

Ready

Enter integers a, b, c and a modulus n, then press Calculate to verify the identities.

How the Is Modulo Multiplication and Addition Associative, Distributive, and Commutative? works

Modular arithmetic — sometimes called "clock arithmetic" — works with the remainder left over after dividing by a fixed modulus n. Formally, mod(x, n) is defined as the unique value r with 0 ≤ r < n such that x = kn + r for some integer k, which in code is ((x % n) + n) % n so it stays correct even for negative x. The set of remainders {0, 1, …, n−1} under addition and multiplication mod n forms what mathematicians call a commutative ring, and this calculator lets you plug in three integers a, b, c and a modulus n to see, concretely, why addition and multiplication mod n are always associative and commutative, and why multiplication always distributes over addition mod n.

Formula and method

The calculator checks four identities directly by computing both sides and comparing them:

  • Associativity of addition: ((a + b) mod n + c) mod n = (a + (b + c) mod n) mod n
  • Associativity of multiplication: ((a × b) mod n × c) mod n = (a × (b × c) mod n) mod n
  • Distributivity: a × (b + c) mod n = ((a × b) mod n + (a × c) mod n) mod n
  • Commutativity: a + b mod n = b + a mod n, and a × b mod n = b × a mod n

Why these hold for every modulus

Reducing a number mod n is a ring homomorphism from the integers ℤ onto ℤ/nℤ: it maps sums to sums and products to products. Since ordinary integer addition and multiplication are already associative, commutative, and mutually distributive, taking remainders never breaks those laws — the same relationships simply carry over to the reduced values, for any n ≥ 1. That is why every check below always comes back "Yes"; the calculator's job is to make that abstract guarantee concrete with your own numbers.

Operations that do not share these properties

  • Subtraction is not commutative: a − b mod n generally differs from b − a mod n unless a ≡ b (mod n).
  • Division is not always defined: a ÷ b mod n only makes sense when b has a multiplicative inverse mod n, which requires gcd(b, n) = 1.
  • Exponentiation is neither commutative nor associative in general: a^b mod n ≠ b^a mod n, and (a^b)^c mod n ≠ a^(b^c) mod n.

Where this matters

  • Cryptography (RSA, Diffie-Hellman) relies on associativity and distributivity mod n to make modular exponentiation computable via repeated squaring.
  • Hash tables and checksums use the fact that (a + b) mod n can be computed incrementally, one addition at a time, without recomputing the whole sum.
  • The Chinese Remainder Theorem and other number-theory algorithms depend on addition and multiplication mod n behaving exactly like their integer counterparts.

Frequently Asked Questions

Is addition modulo n always associative?
Yes. For any integers a, b, c and modulus n ≥ 1, ((a + b) mod n + c) mod n always equals (a + (b + c) mod n) mod n, because modular addition is just ordinary integer addition followed by taking a remainder, and remainders preserve associativity.
Is multiplication modulo n always associative?
Yes. ((a × b) mod n × c) mod n always equals (a × (b × c) mod n) mod n for the same reason: multiplication mod n reduces ordinary integer multiplication, which is already associative, so the property carries over exactly.
Does multiplication distribute over addition modulo n?
Yes. a × (b + c) mod n always equals ((a × b) mod n + (a × c) mod n) mod n. This distributive law is what makes techniques like modular exponentiation and Chinese Remainder Theorem arithmetic valid.
Are addition and multiplication modulo n commutative?
Yes, for every pair of integers a and b: a + b ≡ b + a (mod n) and a × b ≡ b × a (mod n), for any modulus n ≥ 1. Order never matters for either operation under a modulus.