Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · Early undergraduate

Congruences

Name: ______________________

Date: ______________________

You will learn to

  • Prove that congruence modulo nn is an equivalence relation compatible with addition and multiplication, and use it to compute with remainders
  • Decide when aa has an inverse modulo nn and solve linear congruences ax≡b(modn)ax \equiv b \pmod n using Euclid's algorithm
  • State and prove the Chinese remainder theorem, and solve systems of congruences with coprime moduli
  • Prove Fermat's little theorem, Euler's theorem and Wilson's theorem, and use them to compute large powers modulo nn
  • Explain why the converse of Fermat's theorem fails, using the Carmichael number 561561
  1. 1.

    Which of these statements are true? (Choose all that apply.)

    • A.−3≡11(mod7)-3 \equiv 11 \pmod 7
    • B.100≡1(mod9)100 \equiv 1 \pmod 9
    • C.2⋅5≡2⋅8(mod6)2 \cdot 5 \equiv 2 \cdot 8 \pmod 6, so 5≡8(mod6)5 \equiv 8 \pmod 6
    • D.a≡b(mod12)a \equiv b \pmod{12} implies a≡b(mod4)a \equiv b \pmod 4
    • E.210≡20(mod10)2^{10} \equiv 2^{0} \pmod{10}, because 10≡0(mod10)10 \equiv 0 \pmod{10}
  2. 2.

    What is the last digit of 320263^{2026}?

  3. 3.

    Find the inverse of 1717 modulo 4343: the x∈{1,…,42}x \in \{1, \dots, 42\} with 17x≡1(mod43)17x \equiv 1 \pmod{43}.

  4. 4.

    Find the smallest positive integer xx with x≡2(mod5)x \equiv 2 \pmod 5, x≡3(mod7)x \equiv 3 \pmod 7 and x≡4(mod9)x \equiv 4 \pmod 9.

  5. 5.

    How many solutions modulo 3636 does the congruence 8x≡12(mod36)8x \equiv 12 \pmod{36} have?

  6. 6.

    The second proof of Fermat's theorem reaches ap−1(p−1)!≡(p−1)!(modp)a^{p-1}(p-1)! \equiv (p-1)! \pmod p and then cancels (p−1)!(p-1)!. What justifies the cancellation?

    • A.(p−1)!(p-1)! is coprime to pp, because the prime pp divides none of the factors 1,…,p−11, \dots, p - 1 (Euclid's lemma)
    • B.(p−1)!≡−1(modp)(p-1)! \equiv -1 \pmod p, by Wilson's theorem
    • C.Any non-zero number can be cancelled in a congruence
    • D.(p−1)!(p-1)! is smaller than pp
  7. 7.

    Claim: "If an−1≡1(modn)a^{n-1} \equiv 1 \pmod n for every aa coprime to nn, then nn is prime." Which number is a counterexample?

    • A.341=11⋅31341 = 11 \cdot 31
    • B.561=3⋅11⋅17561 = 3 \cdot 11 \cdot 17
    • C.91=7⋅1391 = 7 \cdot 13
    • D.9797
  8. 8.

    Which Lean statement correctly formalises the existence half of the Chinese remainder theorem? (IsCoprime m n means um+vn=1um + vn = 1 for some u,vu, v.)

    • A.theorem t {m n : ℤ} (h : IsCoprime m n) (a b : ℤ) : ∃ x, x ≡ a [ZMOD m] ∧ x ≡ b [ZMOD n]
    • B.theorem t {m n : ℤ} (a b : ℤ) : ∃ x, x ≡ a [ZMOD m] ∧ x ≡ b [ZMOD n]
    • C.theorem t {m n : ℤ} (h : IsCoprime m n) (a b : ℤ) : ∀ x, x ≡ a [ZMOD m] ∧ x ≡ b [ZMOD n]
    • D.theorem t {m n x y : ℤ} (h : IsCoprime m n) (hm : x ≡ y [ZMOD m]) (hn : x ≡ y [ZMOD n]) : x ≡ y [ZMOD m * n]
  9. 9.

    Write crt(residues, moduli) that returns the smallest x≥0x \ge 0 with x≡ri(modmi)x \equiv r_i \pmod{m_i} for all ii, assuming the moduli are pairwise coprime. Combine the congruences one at a time, using an inverse modulo mim_i (Python's pow(a, -1, m) computes one). Then check Sunzi's answer.

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0