Congruence behaves well with respect to operations: you can “reduce modulo nn” at any moment of the computation, which makes even otherwise enormous powers feasible.

Property — Compatibility with operations

If aa(modn)a\equiv a'\pmod n and bb(modn)b\equiv b'\pmod n, then a+ba+b(modn),abab(modn),ak(a)k(modn).a+b \equiv a'+b'\pmod n, \quad a\cdot b\equiv a'\cdot b'\pmod n, \quad a^k\equiv (a')^k\pmod n. Modular arithmetic “respects” the operations of sum, product and power. Not always division: 2x4(mod6)2x\equiv 4\pmod 6 does not imply x2x\equiv 2 (also x=5x=5 works). Modular division requires mcd(a,n)=1\mathrm{mcd}(a,n)=1.

Example — Fast computation of modular powers

7100(mod13)7^{100}\pmod{13}. By Fermat 7121(mod13)7^{12}\equiv 1\pmod{13}. Then 7100=79674=(712)87474=2401=13184+99(mod13).7^{100} = 7^{96}\cdot 7^4 = (7^{12})^8\cdot 7^4\equiv 7^4 = 2401 = 13\cdot 184 + 9\equiv 9\pmod{13}.

Topics: Distribuzioni probabilita
Concepts: Aritmetica modulare · Congruenza
Methods: Aritmetica modulare
Skills: Calcolare · Usare formule