## Sunday, 31 May 2015

### Commutative, Associative, and Distributive Law in Modulo

I still remember the old days when we learned about the Distributive, Associative, and Commutative Law in Addition, Subtraction, Multiplication, and Division in the Elementary School. If you already forget what the law stated, here I describe again:

Commutative:
Commutative Law means we can change the position of the numbers and still get the same result.
Working on:
Addition: 5 + 6 = 6 + 5
Multiplication: 5 x 6 = 6 x 5

Not Working On:
Subtraction: 5-6 != 6-5
Division: 5/6 != 6/5

Associative:
Associative Law means we can change the group of the numbers and still get the same result.
Working on:
Addition: (5 + 6) + 7 = 5 + (6 + 7)
Multiplication: (5 x 6) x 7 = 5 x (6 x 7)
Division: (5 / 6) / 7 != 5 / (6 / 7)

Not Working On:
Subtraction: (5 - 6) - 7 != 5 - (6 - 7)

Distributive:
Distributed Law means we can distribute the number into group of the numbers and still get the same result.
Example:
5 x (6 + 5) = 5 x 6 + 5 x 5

How about the Modulo? Is the same law can working in the Modulo?
Commutative:
Not working: 7 % 5 % 3 != 7 % 3 % 5

Associative:
Not working: (7 % 5) % 3 != 7 % (5 % 3)

Distributive:
Not working if the group come second: 7 % (5 + 3) != (7 % 5) + (7 % 3)
But working if the group come first    : (7 + 5) % 3 = (7 % 3) + (5 % 3)