Intermediate

Is Modulo Associative? Calculator

Enter three integers a, b, c and this tool computes both (a mod b) mod c and a mod (b mod c), checks whether they are equal, and explains why modulo fails the associative property in general.
Dividend (integer)
Modulus 1 (non-zero integer)
Modulus 2 (non-zero integer)
NOT equal — modulo is not associative
Left-associative: (a mod b) mod c
(17 mod 5) mod 3 = 2 mod 3 = 2
Right-associative: a mod (b mod c)
17 mod (5 mod 3) = 17 mod 2 = 1
(a mod b) mod c
2
a mod (b mod c)
1
a mod b
2
b mod c
2
00.511.522.533.54(a%b)%ca%(b%c)Comparing the two remainder values on a number line
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

Modulo is NOT associative: (a mod b) mod c ≠ a mod (b mod c) in general. Enter integers a, b, c to compute both groupings and see whether they coincide for your specific values. The difference arises because each grouping reduces a different pair first, giving different intermediate remainders.

Formula
Left: (a mod b) mod c • Right: a mod (b mod c) — in general, these differ.
How this is calculated

A binary operation ⊕ is associative if (a ⊕ b) ⊕ c = a ⊕ (b ⊕ c) for all values of a, b, c. Addition and multiplication are associative; subtraction and division are not. Modulo (remainder after integer division) is also NOT associative in general — the left-hand grouping (a mod b) mod c and the right-hand grouping a mod (b mod c) usually give different results.

To see why: (17 mod 5) mod 3 = 2 mod 3 = 2, but 17 mod (5 mod 3) = 17 mod 2 = 1. The two groupings first reduce different pairs of numbers, so the intermediate remainders diverge and the final results differ.

The calculator uses the truncated modulo convention (the sign follows the dividend, matching the % operator in most programming languages). The right-hand expression requires b mod c ≠ 0; if b mod c equals zero the divisor in the second operation would be zero, which is undefined. Even when the results happen to be equal for a particular triplet, this is a coincidence — modulo lacks the algebraic guarantee of associativity.

Frequently asked questions

Associativity requires that regrouping never changes the result. With modulo, changing the grouping changes which intermediate reduction happens first: (a mod b) discards multiples of b before the outer mod, while a mod (b mod c) first reduces b by c. These two paths generally produce different remainders.

Yes — the results coincide for some specific triplets (for example when a < b mod c, or when both sides happen to land on the same remainder). But this equality is not guaranteed for all integers, so modulo is not called associative.

The truncated modulo: the remainder has the same sign as the dividend (matches the % operator in C, Java, JavaScript). For positive operands, all modulo conventions agree.

Also known as

is modulo associative
modulo associativity test
mod operator associative property
remainder associativity calculator
modular arithmetic associative test
a mod b mod c calculator
modulo grouping comparison

APA

TG we-Calculate Editorial Team. (2026). Is Modulo Associative? Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/is-modulo-associative-calculator

Chicago

TG we-Calculate Editorial Team. "Is Modulo Associative? Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/is-modulo-associative-calculator.

IEEE

TG we-Calculate Editorial Team, "Is Modulo Associative? Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/is-modulo-associative-calculator

BibTeX

@misc{wecalculate_is_modulo_associative_calculator, title = {Is Modulo Associative? Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/is-modulo-associative-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?