Skip to content
Infinitesimal Dynamics home
Notebook: 0 XP

Number Theory / Modular arithmetic

Modular Arithmetic

Arithmetic on a clock: congruences, inverses and fast exponentiation.

3 min read · 2 sections · 2 checks

Contents 3 sections
  1. §1Congruence
  2. §2Division and inverses
  3. ?Check yourself

By the end you can

  • Work with congruences modulo nn
  • Find modular inverses when they exist
  • Compute large powers by repeated squaring

Helps to know: GCD and the Euclidean Algorithm

§1Congruence

Congruences can be added, subtracted and multiplied like equations. To find the last digit of 71007^{100}, work modulo 10: the powers of 7 end in 7,9,3,17, 9, 3, 1 and then repeat, and 100100 is a multiple of 44, so the answer is 11.

§2Division and inverses

An inverse of aa modulo nn is a number a−1a^{-1} with a⋅a−1≡1a \cdot a^{-1} \equiv 1. It exists exactly when gcd⁡(a,n)=1\gcd(a, n) = 1, and the extended Euclidean algorithm computes it.

Example 1Inverse of 3 modulo 11

  1. Look for 3x≡1(mod11)3x \equiv 1 \pmod{11}.

Check yourself

  1. Q1
    38 mod 7=38 \bmod 7 =
  2. Q2
    Does 44 have an inverse modulo 1010?