Modulo Properties Calculator: Associative, Commutative, Distributive
Enter three integers and a modulus to verify that modular addition and multiplication are associative, commutative, and distributive. The calculator shows both sides of each equation with your actual numbers so you can see exactly how the properties hold. All three properties are universally true for any non-zero modulus, and the worked steps explain why.
What is modular arithmetic?
Modular arithmetic is a system of integer arithmetic where numbers "wrap around" after reaching a given value called the modulus. Writing a mod n means the non-negative remainder when a is divided by n. For example, 17 mod 5 = 2 because 17 = 3 * 5 + 2. It is used everywhere from clock arithmetic (hours mod 12) to cryptography, checksums, and computer science.
Are the three core properties always true for modulo?
Yes. Modular addition and multiplication inherit their algebraic properties from ordinary integer arithmetic. Because integers satisfy (x+y)+z = x+(y+z) and x+y = y+x and x*(y+z) = x*y+x*z, the same equations hold after reducing both sides by any modulus. The formal argument is: if two integers are congruent mod n, adding or multiplying them by the same integer preserves the congruence. This guarantees all three properties for every non-zero modulus and every integer input, not just the specific values you enter above. Together, these five properties (two commutative, two associative, one distributive) mean the integers mod n always form a commutative ring.
Formulas for modular addition and multiplication
The key reduction identities are: (a + b) mod n = ((a mod n) + (b mod n)) mod n, and (a * b) mod n = ((a mod n) * (b mod n)) mod n. These let you reduce large numbers to their residues first, then combine - a trick that is essential in cryptography where intermediate values can have hundreds of digits. The associative and commutative laws follow immediately from these identities combined with the corresponding laws for integers.
When does modular arithmetic gain even more structure?
When the modulus n is a prime number, the integers mod n form a field rather than just a ring. In a field, every non-zero element has a multiplicative inverse: for every a not divisible by n there exists b such that (a * b) mod n = 1. This is not true for composite moduli in general (for example, 2 has no multiplicative inverse mod 4). Fields are the foundation of elliptic-curve cryptography, the AES block cipher, and Reed-Solomon error-correction codes.
Modular arithmetic properties at a glance
| Property | Operation | Equation | Always true? |
|---|---|---|---|
| Commutative | Addition | (x + y) mod n = (y + x) mod n | Yes |
| Commutative | Multiplication | (x * y) mod n = (y * x) mod n | Yes |
| Associative | Addition | ((x+y)+z) mod n = (x+(y+z)) mod n | Yes |
| Associative | Multiplication | ((x*y)*z) mod n = (x*(y*z)) mod n | Yes |
| Distributive | Mul over Add | (x*(y+z)) mod n = (x*y+x*z) mod n | Yes |
All five properties hold for every pair of integers and every modulus n >= 2. The integers mod n form a commutative ring.
Frequently asked questions
Is modulo addition commutative?
Yes. For any integers x and y and any modulus n, (x + y) mod n always equals (y + x) mod n. This follows directly from the fact that ordinary addition is commutative: x + y = y + x for all integers, so their remainders when divided by n are identical.
Is modulo multiplication commutative?
Yes. For any integers x and y and any modulus n, (x * y) mod n always equals (y * x) mod n. Integer multiplication is commutative (x * y = y * x), so their remainders mod n must agree as well.
Is modulo addition associative?
Yes. For any integers x, y, z and modulus n, ((x + y) + z) mod n = (x + (y + z)) mod n. Rearranging parentheses in modular addition never changes the result, just as in ordinary integer arithmetic.
Is modulo multiplication associative?
Yes. For any integers x, y, z and modulus n, ((x * y) * z) mod n = (x * (y * z)) mod n. The order in which you group the multiplications does not matter.
Is modulo multiplication distributive over modulo addition?
Yes. For any integers x, y, z and modulus n, (x * (y + z)) mod n = ((x * y) + (x * z)) mod n. You can expand a product over a modular sum just as in ordinary algebra.
Can a modulo property ever fail for some choice of numbers?
No. All five properties - two commutative, two associative, one distributive - hold for every triple of integers and every modulus n >= 2. They are theorems inherited from integer arithmetic, not coincidences that depend on the values you choose. This calculator shows the verification with your specific numbers to build intuition, but the result is always "Yes - holds".
What algebraic structure do the integers mod n form?
The integers mod n under addition and multiplication form a commutative ring. When n is prime, the structure becomes a field, meaning every non-zero element has a multiplicative inverse. Composite moduli can also be fields only if n is a prime power and you use a different multiplication rule, but ordinary mod n for composite n is a ring, not a field.