askesis

Number theory: 50 theorems from primes to quadratic residues

Number theory flashcards in LaTeX: primes, gcd and the Euclidean algorithm, congruences, Fermat and Euler, the Chinese remainder theorem and quadratic residues.

MathIntermediate50 cardsFree

Practice now

Study without an account

0 of 50 seen0 graduated
What does a∣ba \mid b mean?

Scheduled with the default Askesis timings. Progress is saved in this browser.

All 50 cards

  1. 1
    What does a∣ba \mid b mean?
    aa divides bb: b=kab = ka for some integer kk
  2. 2
    If d∣ad \mid a and d∣bd \mid b, then…
    d∣ax+byd \mid ax + by for all integers xx and yy
  3. 3
    Division algorithm
    For integers aa and b>0b > 0 there are unique integers qq and rr with a=bq+ra = bq + r and 0≤r<b0 \le r < b
  4. 4
    Prime number
    An integer p>1p > 1 whose only positive divisors are 11 and pp
    1 is neither prime nor composite.
  5. 5
    Fundamental theorem of arithmetic
    Every integer greater than 1 is a product of primes, and that factorization is unique apart from the order of the factors
  6. 6
    Euclid’s lemma
    If a prime pp divides abab, then p∣ap \mid a or p∣bp \mid b
  7. 7
    If a∣bca \mid bc and gcd⁡(a,b)=1\gcd(a, b) = 1, then…
    a∣ca \mid c
  8. 8
    Euclid’s proof that there are infinitely many primes
    Given primes p1,…,pkp_1, \dots, p_k, the number p1p2⋯pk+1p_1 p_2 \cdots p_k + 1 leaves remainder 1 when divided by each of them, so its prime factors are new primes
    The number itself need not be prime: 2⋅3⋅5⋅7⋅11⋅13+1=30031=59⋅5092 \cdot 3 \cdot 5 \cdot 7 \cdot 11 \cdot 13 + 1 = 30031 = 59 \cdot 509.
  9. 9
    To test whether nn is prime, which divisors must you try?
    Only the primes up to n\sqrt{n}
    If n=abn = ab with 1<a≤b1 < a \le b, then a≤na \le \sqrt{n}.
  10. 10
    Sieve of Eratosthenes
    List the numbers 22 to nn. For each unmarked p≤np \le \sqrt{n}, which is prime, cross out the multiples of pp from p2p^2 on. What remains unmarked is prime
  11. 11
    Prime number theorem
    π(x)∼xln⁡x\pi(x) \sim \dfrac{x}{\ln x}, where π(x)\pi(x) counts the primes up to xx
  12. 12
    Number of positive divisors of n=p1a1p2a2⋯pkakn = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k}
    (a1+1)(a2+1)⋯(ak+1)(a_1 + 1)(a_2 + 1) \cdots (a_k + 1)
    Example: 72=23⋅3272 = 2^3 \cdot 3^2 has 4⋅3=124 \cdot 3 = 12 divisors.
  13. 13
    gcd and lcm from prime factorizations
    The gcd takes each prime to the smaller of its two exponents; the lcm takes the larger
    12=22⋅312 = 2^2 \cdot 3 and 18=2⋅3218 = 2 \cdot 3^2 give gcd⁡=2⋅3=6\gcd = 2 \cdot 3 = 6 and lcm⁡=22⋅32=36\operatorname{lcm} = 2^2 \cdot 3^2 = 36.
  14. 14
    Product of gcd⁡(a,b)\gcd(a, b) and lcm⁡(a,b)\operatorname{lcm}(a, b)
    gcd⁡(a,b)⋅lcm⁡(a,b)=ab\gcd(a, b) \cdot \operatorname{lcm}(a, b) = ab for positive integers aa and bb
  15. 15
    Euclidean algorithm
    Replace (a,b)(a, b) with (b,a mod b)(b, a \bmod b) until the remainder is 00; the last nonzero remainder is gcd⁡(a,b)\gcd(a, b)
    It works because gcd⁡(a,b)=gcd⁡(b,a mod b)\gcd(a, b) = \gcd(b, a \bmod b).
  16. 16
    gcd⁡(252,105)\gcd(252, 105)
    2121
    252=2⋅105+42252 = 2 \cdot 105 + 42, 105=2⋅42+21105 = 2 \cdot 42 + 21, 42=2⋅2142 = 2 \cdot 21.
  17. 17
    Bézout’s identity
    For integers aa and bb, not both zero, there are integers xx and yy with ax+by=gcd⁡(a,b)ax + by = \gcd(a, b)
    The gcd is the smallest positive integer of the form ax+byax + by. The extended Euclidean algorithm finds xx and yy.
  18. 18
    Coprime (relatively prime) integers
    Integers aa and bb with gcd⁡(a,b)=1\gcd(a, b) = 1
  19. 19
    When does ax+by=cax + by = c have integer solutions?
    Exactly when gcd⁡(a,b)∣c\gcd(a, b) \mid c
  20. 20
    All integer solutions of ax+by=cax + by = c, given one solution (x0,y0)(x_0, y_0)
    x=x0+bd tx = x_0 + \dfrac{b}{d}\,t, y=y0−ad ty = y_0 - \dfrac{a}{d}\,t for integers tt, where d=gcd⁡(a,b)d = \gcd(a, b)
  21. 21
    What does a≡b(modn)a \equiv b \pmod{n} mean?
    n∣a−bn \mid a - b: aa and bb leave the same remainder when divided by nn
  22. 22
    If a≡ba \equiv b and c≡d(modn)c \equiv d \pmod{n}, then…
    a+c≡b+da + c \equiv b + d, ac≡bdac \equiv bd and ak≡bk(modn)a^k \equiv b^k \pmod{n}
  23. 23
    When can you cancel cc from ac≡bc(modn)ac \equiv bc \pmod{n}?
    When gcd⁡(c,n)=1\gcd(c, n) = 1. In general, a≡b(modn/gcd⁡(c,n))a \equiv b \pmod{n / \gcd(c, n)}
  24. 24
    When does aa have an inverse modulo nn?
    Exactly when gcd⁡(a,n)=1\gcd(a, n) = 1
    Bézout gives it: if ax+ny=1ax + ny = 1, then xx is the inverse of aa.
  25. 25
    Inverse of 33 modulo 77
    55, since 3⋅5=15≡1(mod7)3 \cdot 5 = 15 \equiv 1 \pmod{7}
  26. 26
    How many solutions does ax≡b(modn)ax \equiv b \pmod{n} have?
    None unless d=gcd⁡(a,n)d = \gcd(a, n) divides bb; if it does, exactly dd solutions modulo nn
  27. 27
    When are the integers modulo nn a field?
    Exactly when nn is prime
  28. 28
    Why does the digit-sum test for divisibility by 3 and 9 work?
    Because 10≡1(mod9)10 \equiv 1 \pmod{9}, every power of 10 is ≡1\equiv 1, so a number is congruent to its digit sum modulo 9, and so also modulo 3
  29. 29
    Computing ak mod na^k \bmod n efficiently
    Repeated squaring: square repeatedly, multiply in the powers that match the 1 bits of kk, and reduce modulo nn at each step
    It takes at most 2log⁡2k2\log_2 k multiplications instead of k−1k - 1.
  30. 30
    Fermat’s little theorem
    If pp is prime and p∤ap \nmid a, then ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}
    Equivalently, ap≡a(modp)a^p \equiv a \pmod{p} for every integer aa.
  31. 31
    2100 mod 72^{100} \bmod 7
    22
    23=8≡1(mod7)2^3 = 8 \equiv 1 \pmod{7} and 100=3⋅33+1100 = 3 \cdot 33 + 1, so 2100≡22^{100} \equiv 2.
  32. 32
    Euler’s totient φ(n)\varphi(n)
    The number of integers from 11 to nn that are coprime to nn
  33. 33
    φ(pk)\varphi(p^k) for a prime pp
    pk−pk−1=pk−1(p−1)p^k - p^{k-1} = p^{k-1}(p - 1)
    In particular φ(p)=p−1\varphi(p) = p - 1.
  34. 34
    Formula for φ(n)\varphi(n) from the prime factors of nn
    φ(n)=n∏p∣n(1−1p)\varphi(n) = n \displaystyle\prod_{p \mid n} \left(1 - \frac{1}{p}\right)
    φ\varphi is multiplicative: φ(mn)=φ(m) φ(n)\varphi(mn) = \varphi(m)\,\varphi(n) when gcd⁡(m,n)=1\gcd(m, n) = 1.
  35. 35
    φ(36)\varphi(36)
    1212
    36(1−12)(1−13)=1236 \left(1 - \tfrac{1}{2}\right)\left(1 - \tfrac{1}{3}\right) = 12
  36. 36
    Euler’s theorem
    If gcd⁡(a,n)=1\gcd(a, n) = 1, then aφ(n)≡1(modn)a^{\varphi(n)} \equiv 1 \pmod{n}
    Fermat’s little theorem is the case n=pn = p.
  37. 37
    Order of aa modulo nn
    The smallest k>0k > 0 with ak≡1(modn)a^k \equiv 1 \pmod{n}, for gcd⁡(a,n)=1\gcd(a, n) = 1; it always divides φ(n)\varphi(n)
  38. 38
    Primitive root modulo nn
    An aa whose order modulo nn is φ(n)\varphi(n), so its powers run through every residue coprime to nn
    Primitive roots exist exactly when nn is 11, 22, 44, pkp^k or 2pk2p^k for an odd prime pp.
  39. 39
    Carmichael number
    A composite nn with an−1≡1(modn)a^{n-1} \equiv 1 \pmod{n} for every aa coprime to nn, so it passes the Fermat primality test for all such bases
    The smallest is 561=3⋅11⋅17561 = 3 \cdot 11 \cdot 17.
  40. 40
    Wilson’s theorem
    An integer n>1n > 1 is prime exactly when (n−1)!≡−1(modn)(n - 1)! \equiv -1 \pmod{n}
    Example: 6!=720=7⋅103−1≡−1(mod7)6! = 720 = 7 \cdot 103 - 1 \equiv -1 \pmod{7}.
  41. 41
    Chinese remainder theorem
    If n1,…,nkn_1, \dots, n_k are pairwise coprime, the system x≡ai(modni)x \equiv a_i \pmod{n_i} has exactly one solution modulo n1n2⋯nkn_1 n_2 \cdots n_k
  42. 42
    Solve x≡2(mod3)x \equiv 2 \pmod{3}, x≡3(mod5)x \equiv 3 \pmod{5}, x≡2(mod7)x \equiv 2 \pmod{7}
    x≡23(mod105)x \equiv 23 \pmod{105}
    The classic puzzle from the Sunzi Suanjing, a Chinese text from around the 3rd to 5th century.
  43. 43
    Quadratic residue modulo nn
    An aa coprime to nn for which x2≡a(modn)x^2 \equiv a \pmod{n} has a solution
  44. 44
    Quadratic residues modulo 77
    11, 22 and 44
    The squares of 1,…,61, \dots, 6 are 1,4,2,2,4,11, 4, 2, 2, 4, 1 modulo 7.
  45. 45
    How many nonzero quadratic residues are there modulo an odd prime pp?
    Exactly p−12\frac{p-1}{2}; the other p−12\frac{p-1}{2} nonzero residues are non-residues
  46. 46
    Legendre symbol (ap)\left(\frac{a}{p}\right)
    11 if aa is a quadratic residue modulo the odd prime pp, −1-1 if it is a non-residue, and 00 if p∣ap \mid a
  47. 47
    Euler’s criterion
    (ap)≡a(p−1)/2(modp)\left(\dfrac{a}{p}\right) \equiv a^{(p-1)/2} \pmod{p} for an odd prime pp
  48. 48
    When is −1-1 a quadratic residue modulo an odd prime pp?
    Exactly when p≡1(mod4)p \equiv 1 \pmod{4}
  49. 49
    Law of quadratic reciprocity
    For distinct odd primes pp and qq: (pq)(qp)=(−1)p−12⋅q−12\left(\dfrac{p}{q}\right)\left(\dfrac{q}{p}\right) = (-1)^{\frac{p-1}{2} \cdot \frac{q-1}{2}}
    So the two symbols are equal unless both pp and qq are ≡3(mod4)\equiv 3 \pmod{4}.
  50. 50
    Which odd primes are a sum of two squares?
    Exactly those with p≡1(mod4)p \equiv 1 \pmod{4}
    Fermat’s theorem on sums of two squares; for example 13=22+3213 = 2^2 + 3^2.

Frequently asked questions

What background do I need?

Comfort with algebra and simple proofs. The deck matches a first course in elementary number theory or the number theory part of discrete math.

Is it useful for cryptography?

Yes. Modular inverses, fast exponentiation, Fermat’s and Euler’s theorems and the Chinese remainder theorem are the math behind RSA and Diffie–Hellman.

Does it help with math competitions?

It covers the core results that olympiad number theory problems build on, though competitions go much further.

How are formulas displayed?

With LaTeX rendered by KaTeX, so congruences and symbols look like your textbook.