0

(abc)%n = (((ab)%n)c)%n = (((ac)%n)b)%n

Means, result is always same even if I apply on each step or once at end.

For Ex. a=3, b=2, c=3, n=5, always gives answer 4.

Why it feels weird to me?

If I assume modulo as clock with numbers from 0-4, we walk on this clock from 0-∞ and always remains on clock. But distance traveled in above cases is very different but still final position is same.

  1. 36=729 and final position is 4
  2. 32=9, and 43=64, now distance is 9+64=73, much lesser than previous but final position still 4.
  3. 33=27, 22=4, here distance is only 31, but final position still 4.

I don't know if I am using this clock process right, but it feels weird and confusing. Can anyone tell me why they gives same result or point me to some resource.

Monu
  • 111

1 Answers1

1

This is true because taking the residue modulo $n$ is a ring morphism from $\Bbb Z$ to $\Bbb Z{/}n\Bbb Z$. So we can interchange ring operations (like $+,-,\times$ (and their derived operations, like powers) and taking residues modulo $n$. You could formally show it using some recursion on arithmetical expressions, I suppose.

Henno Brandsma
  • 242,131