Self-Assessment Quiz: Modular Arithmetic
Twenty questions to check your understanding. Answer before opening the key. Aim for 16+.
Question 1
The statement $a \equiv b \pmod n$ means, by definition:
A) $a$ and $b$ are both less than $n$ B) $n \mid (a - b)$ C) $a \bmod n = b$ D) $a$ and $b$ are both prime
Question 2
Which is the operator that produces a single number in $\{0, \dots, n-1\}$?
A) $a \equiv b \pmod n$ B) $a \bmod n$ C) $n \mid a$ D) $\gcd(a, n)$
Question 3
The residue $(-7) \bmod 3$, using the non-negative convention of §23.1, is:
A) $-1$ B) $0$ C) $1$ D) $2$
Question 4
Theorem 23.2 lets you transfer which operations from integers to residue classes?
A) addition, subtraction, multiplication B) addition and division only C) all four arithmetic operations including division D) only multiplication
Question 5
From $6 \equiv 0 \pmod 6$ you cannot validly conclude $3 \equiv 0 \pmod 6$ because:
A) $6$ is even B) cancellation requires the cancelled factor ($2$) to be invertible modulo $6$, and it is not C) $0$ has no residue class D) the congruence is false
Question 6
The integer $a$ has an inverse modulo $n$ if and only if:
A) $a < n$ B) $a$ is prime C) $\gcd(a, n) = 1$ D) $n$ is prime
Question 7
Which Chapter 22 result is used to construct the modular inverse when $\gcd(a, n) = 1$?
A) the Fundamental Theorem of Arithmetic B) Bézout's identity (via the extended Euclidean algorithm) C) the sieve of Eratosthenes D) the well-ordering principle
Question 8
The congruence $4x \equiv 3 \pmod 6$ has how many solutions modulo $6$?
A) $0$ B) $1$ C) $2$ D) $6$
Question 9
The congruence $6x \equiv 4 \pmod 8$ has how many solutions modulo $8$? (Recall $g = \gcd(6,8) = 2$ and $2 \mid 4$.)
A) $0$ B) $1$ C) $2$ D) $8$
Question 10
The Chinese Remainder Theorem (Theorem 23.5) guarantees a unique solution modulo $N = \prod n_i$ provided the moduli are:
A) all prime B) all even C) pairwise coprime D) consecutive integers
Question 11
In the CRT construction $x = \sum_i a_i N_i M_i$ with $N_i = N / n_i$, the number $M_i$ is:
A) the residue $a_i$ B) the inverse of $N_i$ modulo $n_i$ C) the product of all moduli D) the totient of $n_i$
Question 12
Square-and-multiply computes $b^e \bmod n$ in how many multiplications?
A) $O(e)$ B) $O(e^2)$ C) $O(\log e)$ D) $O(\sqrt{e})$
Question 13
In mod_pow, the most important habit for keeping intermediate numbers small is to:
A) compute the full $b^e$ first, then take % n
B) reduce modulo $n$ after every squaring and every multiply
C) only reduce at the very end
D) avoid the modulus entirely
Question 14
Fermat's little theorem states that if $p$ is prime and $p \nmid a$, then:
A) $a^p \equiv 1 \pmod p$ B) $a^{p-1} \equiv 1 \pmod p$ C) $a^{p} \equiv 0 \pmod p$ D) $a^{p+1} \equiv a \pmod p$
Question 15
Euler's totient $\phi(n)$ counts:
A) the prime factors of $n$ B) the integers in $\{1, \dots, n\}$ coprime to $n$ (the units modulo $n$) C) the divisors of $n$ D) the residues equal to their own inverse
Question 16
For distinct primes $p$ and $q$, the value $\phi(pq)$ — the number RSA's key generation uses — is:
A) $pq$ B) $p + q$ C) $(p-1)(q-1)$ D) $pq - 1$
Question 17
Euler's theorem says that if $\gcd(a, n) = 1$, then:
A) $a^{n} \equiv 1 \pmod n$ B) $a^{\phi(n)} \equiv 1 \pmod n$ C) $a^{n-1} \equiv 1 \pmod n$ D) $a^{\phi(n)} \equiv 0 \pmod n$
Question 18 (True/False, justify)
True or false: If you know $x \bmod 6$ and $x \bmod 4$, the CRT lets you determine $x \bmod 24$. Justify in one sentence.
Question 19 (True/False, justify)
True or false: In RSA, the private exponent $d$ satisfies $ed \equiv 1 \pmod{\phi(n)}$, so $d$ is a modular inverse. Justify in one sentence, naming the operation used to compute $d$.
Question 20 (Short answer)
Explain in one or two sentences why Euler's theorem makes RSA decryption recover the message exactly — i.e., why $m^{ed} \equiv m \pmod n$ when $ed \equiv 1 \pmod{\phi(n)}$.
Answer Key
| Q | Ans | Note |
|---|---|---|
| 1 | B | Definition of congruence: $n$ divides the difference. |
| 2 | B | \bmod is the operator; \pmod marks the relation. |
| 3 | D | $-7 = 3\cdot(-3) + 2$, so the non-negative residue is $2$. |
| 4 | A | Add/subtract/multiply transfer (Thm 23.2); division does not. |
| 5 | B | $2$ is not invertible mod $6$ ($\gcd(2,6)=2$), so cancellation is illegal. |
| 6 | C | Inverse exists $\iff \gcd(a,n)=1$ (Thm 23.3). |
| 7 | B | Bézout gives $as + nt = 1$; the extended Euclidean algorithm computes $s$. |
| 8 | A | $g=\gcd(4,6)=2$ and $2 \nmid 3$, so no solution. |
| 9 | C | $g=2$ divides $4$, so exactly $g = 2$ solutions ($x \equiv 2, 6$). |
| 10 | C | Pairwise coprime moduli (Thm 23.5). |
| 11 | B | $M_i = N_i^{-1} \bmod n_i$, the "$\equiv 1$ here, $\equiv 0$ elsewhere" gadget. |
| 12 | C | Square-and-multiply: one squaring per bit of $e$, so $O(\log e)$. |
| 13 | B | Reduce after every operation to keep values below $n^2$. |
| 14 | B | $a^{p-1} \equiv 1 \pmod p$ (Thm 23.6). |
| 15 | B | $\phi(n) = \#\{$units mod $n\}$. |
| 16 | C | $\phi(pq) = (p-1)(q-1)$ for distinct primes. |
| 17 | B | $a^{\phi(n)} \equiv 1 \pmod n$ (Thm 23.7). |
| 18 | False | $\gcd(6,4)=2 \ne 1$, so the moduli aren't coprime; CRT does not apply and you can pin down $x$ only mod $\operatorname{lcm}(6,4)=12$. |
| 19 | True | $d = e^{-1} \bmod \phi(n)$, a modular inverse computed by the extended Euclidean algorithm. |
| 20 | — | $ed = 1 + k\phi(n)$, so $m^{ed} = m \cdot (m^{\phi(n)})^k \equiv m \cdot 1^k = m \pmod n$ by Euler's theorem. |
Topics to review by question
| Questions | Topic |
|---|---|
| 1–3 | Congruence, residues, the ≡-vs-bmod distinction (§23.1) |
| 4–5 | Modular arithmetic rules; why division fails (§23.2) |
| 6–9 | Modular inverses and linear congruences (§23.3) |
| 10–11, 18 | The Chinese Remainder Theorem (§23.4) |
| 12–13 | Fast modular exponentiation (§23.5) |
| 14–17, 20 | Fermat, the totient, and Euler's theorem (§23.6) |
| 19–20 | Why RSA works — the payoff of the whole chapter |