## 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)

Why I'm writing this? Is there any place of the world even concern about this?

There is a problem when we want to take a modulo function for a big number. For example:
8904835093485098039482094853094850249583023948093840298340988405345 % 4
We can count the modulo of the last digit first, and then the second digit multiply by 10, which can be separate into several groups, then we can add all of the sum.

And of course I believe there are many computational problems out there that can be solved by this law.