Skip to content

A.6 · Congruences, divisibility and arithmetic functions

GRE MathematicsTopic 12

Video lesson for this topic Open the video page
5:36

A.6 · Congruences, divisibility and arithmetic functions

In August 1977 Martin Gardner's column in Scientific American printed a message encrypted with a new method, RSA, invented that year by Ron Rivest, Adi Shamir…

English narration · English and 中文 subtitles you can switch

12.1

Congruences, divisibility and arithmetic functions

In August 1977 Martin Gardner's column in Scientific American printed a message encrypted with a new method, RSA, invented that year by Ron Rivest, Adi Shamir and Leonard Adleman. To read it, you would need to factor a 129-digit number. The authors offered $100 and estimated that, with the methods of the day, it would take 40 quadrillion years. In 1994 about 600 volunteers sharing their computers over the internet factored it, and the message read: "The magic words are squeamish ossifrage." RSA rests on congruence 同余 arithmetic and Euler's totient 欧拉函数.

GRE Mathematics number theory questions ask you to:

  • Solve linear congruences and find inverses modulo $n$.
  • Use the Chinese remainder theorem.
  • Apply Fermat's and Euler's theorems, and Wilson's theorem.
  • Compute arithmetic functions such as $\varphi$, $\tau$ and $\sigma$.
Vocabulary Train
English
congruence/ˈkɒŋɡruːəns/
totient/ˈtəʊʃənt/
12.2

Congruences

$a \equiv b \pmod n$ means $n$ divides $a - b$.

  • $ax \equiv b \pmod n$ has a solution exactly when $d = \gcd(a, n)$ divides $b$. Then it has $d$ solutions modulo $n$, spaced $n/d$ apart.
  • To solve, divide $a$, $b$ and $n$ by $d$, solve the smaller congruence, and list the lifts.
  • $a$ has an inverse modulo $n$ exactly when $\gcd(a, n) = 1$; find it with the Euclidean algorithm.
A clock of residues 0 to 14 with 4, 9 and 14 highlighted: 6x is congruent to 9 mod 15 has gcd 3 solutions spaced 5 apart
d = gcd(a, n) solutions, n/d apart.
12.3

The Chinese remainder theorem

If $m$ and $n$ are coprime, the system $x \equiv a \pmod m$, $x \equiv b \pmod n$ has exactly one solution modulo $mn$.

  • Equivalently, $\mathbb Z/mn\mathbb Z \cong \mathbb Z/m\mathbb Z \times \mathbb Z/n\mathbb Z$.
  • If $m$ and $n$ share a factor, a solution exists only when $a \equiv b$ modulo $\gcd(m, n)$.
12.4

Fermat, Euler and Wilson

  • Euler: if $\gcd(a, n) = 1$, then $a^{\varphi(n)} \equiv 1 \pmod n$. For a prime $p$ this is Fermat's little theorem, $a^{p-1} \equiv 1$.
  • Wilson: $p$ is prime exactly when $(p - 1)! \equiv -1 \pmod p$.
  • These theorems need their conditions: Euler's needs $a$ to be a unit.
12.5

Arithmetic functions

If $n = p_1^{a_1}\cdots p_k^{a_k}$:

$$\varphi(n) = n\prod\left(1 - \frac{1}{p_i}\right), \qquad \tau(n) = \prod(a_i + 1), \qquad \sigma(n) = \prod\frac{p_i^{a_i + 1} - 1}{p_i - 1}$$
  • $\varphi$ counts residues coprime to $n$; $\tau$ counts divisors; $\sigma$ adds them.
  • All three are multiplicative: $f(mn) = f(m)f(n)$ when $\gcd(m, n) = 1$.
12.6

Worked example: a congruence with several solutions

Solve $8x \equiv 12 \pmod{20}$.

  • $\gcd(8, 20) = 4$, which divides 12, so there are 4 solutions.
  • Divide by 4: $2x \equiv 3 \pmod 5$, so $x \equiv 4 \pmod 5$ (since $2 \times 4 = 8 \equiv 3$).
  • Modulo 20: $x = 4, 9, 14, 19$. Check: $8 \times 9 = 72 = 60 + 12$.
Table: x = 4, 9 and 14 modulo 15 all give 6x ≡ 9
Solve 2x ≡ 3 (mod 5) to get x ≡ 4, then lift to three solutions modulo 15
12.7

Worked example: inverses and Euler

  • The inverse of 7 modulo 20 is 3, since $21 \equiv 1$.
  • $\varphi(20) = 20 \times \tfrac12 \times \tfrac45 = 8$, so $7^8 \equiv 1 \pmod{20}$.
  • But $2^8 = 256 \equiv 16 \pmod{20}$, not 1: Euler's theorem does not apply, because $\gcd(2, 20) = 2$.
  • CRT: $x \equiv 2 \pmod 3$ and $x \equiv 3 \pmod 5$ give $x \equiv 8 \pmod{15}$.
12.8

Common errors

  • Dividing a congruence by a number that shares a factor with the modulus, without dividing the modulus.
  • Giving one solution when there are $\gcd(a, n)$ of them.
  • Using Euler's theorem for a non-unit.
  • Using the Chinese remainder theorem with moduli that are not coprime.
  • Forgetting that $\varphi$ is multiplicative only for coprime factors.
12.9

Key terms

congruence: The relation $a \equiv b \pmod n$, meaning $n$ divides $a - b$.

totient: Euler's function $\varphi(n)$, the number of residues from 1 to $n$ that are coprime to $n$.

12.10

Check yourself

  • What is $\varphi(36)$?
  • What is $6! \bmod 7$?
  • How many positive divisors does 72 have?

Answers: $36 \times \tfrac12 \times \tfrac23 = 12$. 6, that is $-1$, as Wilson's theorem says. $(3 + 1)(2 + 1) = 12$.

Was this helpful?

Interactive lessons on this topic

Work through it step by step, with instant-check exercises.

More topics in GRE Mathematics

Log in or create account

IGCSE, A-Level & AP