7.3 Modular Arithmetic, Chinese Remainder Theorem, and Euler's Totient

Key Takeaways

  • A modular multiplicative inverse a^{-1} mod m exists if and only if gcd(a, m) = 1, making Z/mZ a field if and only if m is prime.
  • A linear congruence ax = b (mod m) has solutions if and only if d = gcd(a, m) divides b, producing exactly d incongruent solutions modulo m.
  • The Chinese Remainder Theorem guarantees a unique solution modulo the product of pairwise coprime moduli, establishing a fundamental ring isomorphism between modular systems.
  • Euler's Totient Theorem generalizes Fermat's Little Theorem to composite moduli via phi(n) = n * prod_{p|n} (1 - 1/p), enabling exponential reductions alongside Wilson's factorial theorem.
Last updated: September 2026

7.3 Modular Arithmetic, Chinese Remainder Theorem, and Euler's Totient

Modular arithmetic on the GRE tests congruences, inverses, Euler's and Fermat's theorems, and the Chinese Remainder Theorem. Rapid reduction of powers and modular inverses is critical.


Congruence Relations and Modular Fundamentals

For $m \in \mathbb{Z}^+$, integers $a, b$ are congruent modulo $m$, written $a \equiv b \pmod m$, if $m \mid (a - b)$. This partitions $\mathbb{Z}$ into residue classes ${0, 1, \dots, m-1}$.

  • Ring Operations: If $a \equiv b \pmod m$ and $c \equiv d \pmod m$, then $a \pm c \equiv b \pm d \pmod m$ and $ac \equiv bd \pmod m$.
  • Cancellation Rule: ac≡bc(modm)  ⟺  a≡b(modmgcd⁡(c,m))ac \equiv bc \pmod m \iff a \equiv b \pmod{\frac{m}{\gcd(c, m)}} If $\gcd(c, m) = 1$, $ac \equiv bc \pmod m \implies a \equiv b \pmod m$.

Modular Inverses and Linear Congruences

A multiplicative inverse $a^{-1} \pmod m$ satisfies $ax \equiv 1 \pmod m$.

  • Existence: $a^{-1} \pmod m$ exists and is unique modulo $m$ if and only if $\gcd(a, m) = 1$. The ring $\mathbb{Z}/m\mathbb{Z}$ is a field $\mathbb{F}_p$ if and only if $m$ is prime $p$.

Solving Linear Congruences

For $ax \equiv b \pmod m$:

  1. Let $d = \gcd(a, m)$. Solutions exist if and only if $d \mid b$.
  2. If $d \mid b$, there are exactly $d$ incongruent solutions modulo $m$.
  3. Divide through by $d$: $\frac{a}{d}x \equiv \frac{b}{d} \pmod{\frac{m}{d}}$ and invert $\frac{a}{d}$ modulo $\frac{m}{d}$ to find base solution $x_0$.
  4. The complete set of solutions is: x≡x0+k(md)(modm)for k=0,1,…,d−1x \equiv x_0 + k\left(\frac{m}{d}\right) \pmod m \quad \text{for } k = 0, 1, \dots, d-1

The Chinese Remainder Theorem (CRT)

Let $m_1, \dots, m_k$ be pairwise coprime positive integers ($\gcd(m_i, m_j) = 1$ for $i \neq j$). The system $x \equiv a_i \pmod{m_i}$ ($i = 1, \dots, k$) has a unique solution modulo $M = \prod_{i=1}^k m_i$.

Algorithm

  1. Compute $M = \prod m_i$ and $M_i = M/m_i$.
  2. Invert: $y_i \equiv M_i^{-1} \pmod{m_i}$.
  3. Solution: $x \equiv \sum_{i=1}^k a_i M_i y_i \pmod M$. CRT provides the ring isomorphism $\mathbb{Z}/M\mathbb{Z} \cong \prod_{i=1}^k \mathbb{Z}/m_i\mathbb{Z}$.

Fermat's Little Theorem and Euler's Totient Function

Fermat's Little Theorem (FLT)

If $p$ is prime and $p \nmid a$, then: ap−1≡1(modp)andap≡a(modp) for all aa^{p-1} \equiv 1 \pmod p \quad \text{and} \quad a^p \equiv a \pmod p \text{ for all } a

Euler's Totient Function $\phi(n)$

$\phi(n)$ counts integers $1 \le k \le n$ coprime to $n$. For $n = \prod p_i^{a_i}$: ϕ(n)=n∏p∣n(1−1p)=∏i=1kpiai−1(pi−1)\phi(n) = n \prod_{p \mid n} \left(1 - \frac{1}{p}\right) = \prod_{i=1}^k p_i^{a_i - 1}(p_i - 1)

  • Multiplicativity: $\gcd(m, n) = 1 \implies \phi(mn) = \phi(m)\phi(n)$.
  • Gauss Identity: $\sum_{d \mid n} \phi(d) = n$.

Euler's Totient Theorem

If $\gcd(a, n) = 1$, then $a^{\phi(n)} \equiv 1 \pmod n$.


Wilson's Theorem and Fast Exponentiation

Wilson's Theorem

An integer $p > 1$ is prime if and only if: (p−1)!≡−1(modp)(p - 1)! \equiv -1 \pmod p For primes $p > 2$, key corollaries include $(p - 2)! \equiv 1 \pmod p$ and $(p - 3)! \equiv \frac{p-1}{2} \pmod p$.

Successive Squaring

Compute $a^b \bmod m$ in $O(\log b)$ operations by writing $b = \sum c_j 2^j$ in binary and multiplying powers $a^{2^j}$ computed via repeated modular squaring.


Summary Table: Modular Arithmetic Theorems

TheoremHypothesesFundamental IdentityApplication
Fermat's Little$p$ prime, $p \nmid a$$a^{p-1} \equiv 1 \pmod p$Exponent reduction mod prime
Euler's Totient$\gcd(a, n) = 1$$a^{\phi(n)} \equiv 1 \pmod n$Exponent reduction mod composite
Wilson's$p$ prime$(p - 1)! \equiv -1 \pmod p$Factorial evaluation mod prime
Chinese Remainder$\gcd(m_i, m_j) = 1$Unique solution mod $\prod m_i$Simultaneous congruence systems

Step-by-Step Worked Problem

Problem: Find the remainder when $3^{102}$ is divided by $70$.

Solution:

  1. Factor modulus: $70 = 2 \times 5 \times 7$. Moduli are pairwise coprime.
  2. Compute modulo each factor:
    • Modulo 2: $3 \equiv 1 \pmod 2 \implies 3^{102} \equiv 1 \pmod 2$.
    • Modulo 5: By FLT, $3^4 \equiv 1 \pmod 5$. Since $102 = 4(25) + 2$: 3102≡(34)25⋅32≡1⋅9≡4(mod5)3^{102} \equiv (3^4)^{25} \cdot 3^2 \equiv 1 \cdot 9 \equiv 4 \pmod 5
    • Modulo 7: By FLT, $3^6 \equiv 1 \pmod 7$. Since $102 = 6(17)$: 3102≡(36)17≡1(mod7)3^{102} \equiv (3^6)^{17} \equiv 1 \pmod 7
  3. Combine using CRT:
    • $x \equiv 1 \pmod 2$ and $x \equiv 1 \pmod 7 \implies x \equiv 1 \pmod{14}$. Thus $x = 14k + 1$.
    • Modulo 5: $14k + 1 \equiv 4 \pmod 5 \implies 4k \equiv 3 \implies -k \equiv 3 \implies k \equiv 2 \pmod 5$.
    • Smallest positive value ($k = 2$): $x = 14(2) + 1 = 29$.
  4. Check: $29 \equiv 1 \pmod 2$, $29 \equiv 4 \pmod 5$, $29 \equiv 1 \pmod 7$. Remainder is $29$.

GRE Exam Traps & Pitfalls

Trap 1: Cancelling Factors Without Modifying Modulus $4x \equiv 4y \pmod 6$ implies $x \equiv y \pmod 3$, NOT modulo 6. Dividing requires dividing the modulus by $\gcd(c, m)$.

Trap 2: Invoking Euler's Theorem When $\gcd(a, n) > 1$ Euler's theorem requires $\gcd(a, n) = 1$. If non-coprime, factor into prime powers and apply CRT.

Trap 3: Applying Standard CRT to Non-Coprime Moduli Moduli must be pairwise coprime. For non-coprime moduli, decompose into prime-power congruences and verify consistency.

Trap 4: Missing Incongruent Solutions If $d = \gcd(a, m) > 1$ divides $b$, $ax \equiv b \pmod m$ has exactly $d$ distinct solutions modulo $m$, not just 1.

Loading diagram...
Modular Exponentiation and Congruence Strategy
Test Your Knowledge

Find the smallest non-negative integer x that satisfies the system of simultaneous congruences: x = 2 mod 3, x = 3 mod 5, and x = 5 mod 7.

A
B
C
D
Test Your Knowledge

What is the remainder when 7^2026 is divided by 100?

A
B
C
D
Test Your Knowledge

If p = 19, what is the value of 16! mod 19?

A
B
C
D