How this calculator works
The fixed modulus m defines residue classes. Reducing after each addition or multiplication gives the same residue as reducing at the end, so these operations are associative and commutative, and multiplication distributes over addition. In contrast, (a mod b) mod c changes the modulus at each step. It need not equal a mod (b mod c). One counterexample disproves a universal law; agreement for one triple does not prove one. b and c must be positive here so both nested remainder expressions use the same non-negative convention.
Formula
((a+b) mod m+c) mod m=(a+(b+c) mod m) mod m. The analogous product identity holds. (a mod b) mod c need not equal a mod (b mod c).
Worked example
For a=20, b=6 and c=4, (20 mod 6) mod 4=2, while 20 mod (6 mod 4)=0. With fixed modulus 7, the three-term sum is 2 and the three-factor product is 4 under either grouping.
Advertisement
Frequently asked questions
Is the remainder operator associative?
Not in general. The two nested remainder columns can differ, as the default example shows.
Why do modular addition and multiplication work?
They use one fixed modulus throughout. Reducing an intermediate result changes it by a multiple of that same modulus.
Why is b mod c=0 rejected?
It becomes the divisor in the right-hand nesting. Division or remainder by zero is undefined.