๐ŸงฉDiscrete Mathematics

Key Number Theory Concepts

Study smarter with Fiveable

Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.

Get Started

Why This Matters

Number theory forms the mathematical backbone of modern computing and cryptography. In discrete math, you're expected to understand divisibility relationships, modular systems, and the theorems that connect them. These concepts build on each other, from basic divisibility all the way up to the cryptographic applications that secure online transactions.

Don't just memorize definitions and formulas. For each concept, know why it works, how it connects to other ideas, and when you'd apply it. Can you explain why the Euclidean algorithm is efficient? Do you see how Euler's Theorem generalizes Fermat's Little Theorem? Master the underlying logic, and the individual facts will stick.


Foundations: Divisibility and Division

These concepts establish the ground rules for how integers relate to each other. Every theorem that follows depends on understanding what it means for one number to divide another.

Divisibility and Division Algorithm

Divisibility has a precise definition: bb divides aa (written bโˆฃab \mid a) if there exists an integer kk such that a=bโ‹…ka = b \cdot k. For example, 3โˆฃ123 \mid 12 because 12=3โ‹…412 = 3 \cdot 4.

The Division Algorithm guarantees that for any integers aa and bb (with b>0b > 0), there exist unique integers qq (quotient) and rr (remainder) such that:

a=bq+rwhereย 0โ‰คr<ba = bq + r \quad \text{where } 0 \leq r < b

For instance, dividing 17 by 5 gives 17=5(3)+217 = 5(3) + 2, so q=3q = 3 and r=2r = 2. The uniqueness of qq and rr is what makes this a theorem, not just long division.

Greatest Common Divisor (GCD) and Euclidean Algorithm

The GCD of two integers is the largest positive integer that divides both of them. It's the foundation for simplifying fractions and solving equations.

The Euclidean Algorithm computes the GCD efficiently by repeatedly applying the division algorithm. The key identity is:

gcdโก(a,b)=gcdโก(b,aโ€Šmodโ€Šb)\gcd(a, b) = \gcd(b, a \bmod b)

Here's how it works step by step for gcdโก(252,198)\gcd(252, 198):

  1. 252=198(1)+54252 = 198(1) + 54, so gcdโก(252,198)=gcdโก(198,54)\gcd(252, 198) = \gcd(198, 54)
  2. 198=54(3)+36198 = 54(3) + 36, so gcdโก(198,54)=gcdโก(54,36)\gcd(198, 54) = \gcd(54, 36)
  3. 54=36(1)+1854 = 36(1) + 18, so gcdโก(54,36)=gcdโก(36,18)\gcd(54, 36) = \gcd(36, 18)
  4. 36=18(2)+036 = 18(2) + 0, so gcdโก(36,18)=18\gcd(36, 18) = 18

The algorithm terminates when the remainder hits 0. The last nonzero remainder is the GCD.

The Extended Euclidean Algorithm goes further: it finds integers xx and yy such that ax+by=gcdโก(a,b)ax + by = \gcd(a, b). This is critical for solving Diophantine equations and finding modular inverses.

Least Common Multiple (LCM)

The LCM of two integers is the smallest positive integer divisible by both. Think of it as solving synchronization problems: if one event repeats every 6 days and another every 8 days, they coincide every lcm(6,8)=24\text{lcm}(6, 8) = 24 days.

The GCD and LCM are connected by this relationship:

lcm(a,b)=โˆฃaโ‹…bโˆฃgcdโก(a,b)\text{lcm}(a, b) = \frac{|a \cdot b|}{\gcd(a, b)}

This means if you know one, you can always compute the other.

Compare: GCD vs. LCM โ€” both measure divisibility relationships, but GCD finds the largest shared factor while LCM finds the smallest shared multiple. If a problem gives you one, you can compute the other using gcdโก(a,b)โ‹…lcm(a,b)=โˆฃaโ‹…bโˆฃ\gcd(a,b) \cdot \text{lcm}(a,b) = |a \cdot b|.


Prime Numbers: The Building Blocks

Primes are the atoms of number theory. Every integer greater than 1 is either prime or can be broken down into prime factors, and this decomposition is unique.

Prime Numbers and Prime Factorization

A prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. The first several primes are 2, 3, 5, 7, 11, 13, ...

The Fundamental Theorem of Arithmetic states that every integer greater than 1 has a unique prime factorization, up to the ordering of factors. For example, 360=23โ‹…32โ‹…5360 = 2^3 \cdot 3^2 \cdot 5 and no other combination of primes will produce 360.

Prime factorization also gives you a way to compute GCD and LCM: take the minimum power of each shared prime for GCD, and the maximum power of every prime for LCM. For example, with 12=22โ‹…312 = 2^2 \cdot 3 and 18=2โ‹…3218 = 2 \cdot 3^2:

  • gcdโก(12,18)=21โ‹…31=6\gcd(12, 18) = 2^1 \cdot 3^1 = 6
  • lcm(12,18)=22โ‹…32=36\text{lcm}(12, 18) = 2^2 \cdot 3^2 = 36

Linear Diophantine Equations

A linear Diophantine equation has the form ax+by=cax + by = c, where a,b,ca, b, c are integers and you need integer solutions for xx and yy.

The existence criterion is clean: solutions exist if and only if gcdโก(a,b)\gcd(a, b) divides cc. For example, 6x+9y=126x + 9y = 12 has solutions because gcdโก(6,9)=3\gcd(6, 9) = 3 and 3โˆฃ123 \mid 12. But 6x+9y=116x + 9y = 11 has no integer solutions because 3โˆค113 \nmid 11.

Once you find one particular solution (using the Extended Euclidean Algorithm), the general solution generates infinitely many solutions parameterized by an integer tt.

Compare: Prime factorization vs. Euclidean algorithm for finding GCD โ€” factorization gives conceptual insight but is computationally expensive for large numbers. The Euclidean algorithm is efficient even for massive integers. Know when to use each approach.


Modular Arithmetic: Computing with Remainders

Modular arithmetic transforms infinite integer problems into finite, cyclic systems. This is where number theory meets practical computation.

Modular Arithmetic Basics

The core idea: work with remainders when dividing by a fixed modulus mm, reducing the infinite integers to a finite set {0,1,โ€ฆ,mโˆ’1}\{0, 1, \ldots, m-1\}.

The congruence notation aโ‰กb(modm)a \equiv b \pmod{m} means aa and bb have the same remainder when divided by mm. Equivalently, mโˆฃ(aโˆ’b)m \mid (a - b). For example, 17โ‰ก2(mod5)17 \equiv 2 \pmod{5} because 5โˆฃ(17โˆ’2)5 \mid (17 - 2).

Clock arithmetic is the classic example: 14:00 and 2:00 are the same on a 12-hour clock because 14โ‰ก2(mod12)14 \equiv 2 \pmod{12}.

Congruences and Their Properties

Congruence modulo mm is an equivalence relation, meaning it's reflexive, symmetric, and transitive. This lets you manipulate congruences algebraically, much like equations.

Arithmetic works as expected for addition and multiplication. If aโ‰กb(modm)a \equiv b \pmod{m}, then:

  • a+cโ‰กb+c(modm)a + c \equiv b + c \pmod{m}
  • aโ‹…cโ‰กbโ‹…c(modm)a \cdot c \equiv b \cdot c \pmod{m}

Division is the exception. You can only divide (cancel) both sides by cc if gcdโก(c,m)=1\gcd(c, m) = 1. For example, 6โ‰ก6(mod6)6 \equiv 6 \pmod{6} is trivially true, but dividing both sides by 2 gives 3โ‰ก3(mod6)3 \equiv 3 \pmod{6}, which happens to work. However, 4โ‰ก10(mod6)4 \equiv 10 \pmod{6} is true (both leave remainder 4 mod 6), but dividing by 2 gives 2โ‰ก5(mod6)2 \equiv 5 \pmod{6}, which is false. The safe rule: only cancel cc when gcdโก(c,m)=1\gcd(c, m) = 1.

Compare: Modular addition/multiplication vs. modular division โ€” the first two always preserve congruence, but division requires the divisor to be coprime with the modulus. This distinction is crucial for solving congruence equations.


Power Theorems: Fermat and Euler

These theorems reveal deep structure in modular exponentiation. They're not just theoretical; they power modern cryptography.

Fermat's Little Theorem

Statement: If pp is prime and gcdโก(a,p)=1\gcd(a, p) = 1, then:

apโˆ’1โ‰ก1(modp)a^{p-1} \equiv 1 \pmod{p}

There's also a corollary form that drops the coprimality requirement: for any integer aa, apโ‰กa(modp)a^p \equiv a \pmod{p}. This version holds even when pp divides aa.

The main use in practice is reducing large exponents. For example, to compute 3100(mod7)3^{100} \pmod{7}: since 7 is prime and gcdโก(3,7)=1\gcd(3, 7) = 1, you know 36โ‰ก1(mod7)3^6 \equiv 1 \pmod{7}. Then 3100=36โ‹…16+4=(36)16โ‹…34โ‰ก116โ‹…81โ‰ก81(mod7)3^{100} = 3^{6 \cdot 16 + 4} = (3^6)^{16} \cdot 3^4 \equiv 1^{16} \cdot 81 \equiv 81 \pmod{7}. And 81=7(11)+481 = 7(11) + 4, so 3100โ‰ก4(mod7)3^{100} \equiv 4 \pmod{7}.

Euler's Theorem and Euler's Totient Function

Euler's Theorem generalizes Fermat to any modulus: if gcdโก(a,n)=1\gcd(a, n) = 1, then:

aฯ•(n)โ‰ก1(modn)a^{\phi(n)} \equiv 1 \pmod{n}

The totient function ฯ•(n)\phi(n) counts the integers from 1 to nn that are coprime to nn. Key formulas:

  • For a prime pp: ฯ•(p)=pโˆ’1\phi(p) = p - 1
  • For a prime power: ฯ•(pk)=pkโˆ’pkโˆ’1=pkโˆ’1(pโˆ’1)\phi(p^k) = p^k - p^{k-1} = p^{k-1}(p - 1)
  • For coprime integers: ฯ•(mn)=ฯ•(m)ฯ•(n)\phi(mn) = \phi(m)\phi(n) when gcdโก(m,n)=1\gcd(m, n) = 1

These formulas combine to handle any integer via its prime factorization. For example, ฯ•(12)=ฯ•(4)ฯ•(3)=(4โˆ’2)(3โˆ’1)=2โ‹…2=4\phi(12) = \phi(4)\phi(3) = (4 - 2)(3 - 1) = 2 \cdot 2 = 4. The four integers from 1 to 12 coprime to 12 are: 1, 5, 7, 11.

Compare: Fermat's Little Theorem vs. Euler's Theorem โ€” Fermat works only for prime moduli, while Euler handles any modulus (with coprimality). When n=pn = p is prime, ฯ•(p)=pโˆ’1\phi(p) = p - 1, so Euler's reduces exactly to Fermat's. Exam questions often ask you to identify which theorem applies.


Systems of Congruences: The Chinese Remainder Theorem

When you need to solve multiple congruences simultaneously, the Chinese Remainder Theorem (CRT) provides the tool.

Chinese Remainder Theorem

Statement: Given pairwise coprime moduli m1,m2,โ€ฆ,mkm_1, m_2, \ldots, m_k, the system of congruences

xโ‰กa1(modm1),xโ‰กa2(modm2),โ€ฆ,xโ‰กak(modmk)x \equiv a_1 \pmod{m_1}, \quad x \equiv a_2 \pmod{m_2}, \quad \ldots, \quad x \equiv a_k \pmod{m_k}

has a unique solution modulo M=m1โ‹…m2โ‹ฏmkM = m_1 \cdot m_2 \cdots m_k.

The pairwise coprimality requirement is essential. If two moduli share a common factor, the system might have no solution or might not have a unique one modulo MM. For example, xโ‰ก1(mod4)x \equiv 1 \pmod{4} and xโ‰ก2(mod6)x \equiv 2 \pmod{6} has no solution because any number that's 1 mod 4 is odd, but any number that's 2 mod 6 is even.

CRT is powerful because it lets you break a hard problem into easier pieces. To compute something mod 105, you can work mod 3, mod 5, and mod 7 separately (since 105=3โ‹…5โ‹…7105 = 3 \cdot 5 \cdot 7), then reconstruct the answer. Computer algebra systems use this technique extensively.

Compare: Solving single congruences vs. systems via CRT โ€” single congruences use basic modular arithmetic or the Extended Euclidean Algorithm, while systems require CRT's decomposition approach. You should verify coprimality before applying CRT.


Quick Reference Table

ConceptKey Tools
Divisibility foundationsDivision algorithm, GCD, LCM
Efficient computationEuclidean algorithm, Extended Euclidean algorithm
Unique factorizationFundamental Theorem of Arithmetic, prime factorization
Integer equationsLinear Diophantine equations, existence via GCD
Modular systemsCongruences, modular arithmetic properties
Prime modulus theoremsFermat's Little Theorem
General modulus theoremsEuler's Theorem, totient function
Simultaneous congruencesChinese Remainder Theorem

Self-Check Questions

  1. What condition must be satisfied for the linear Diophantine equation ax+by=cax + by = c to have integer solutions, and how does this connect to the Euclidean algorithm?

  2. Compare Fermat's Little Theorem and Euler's Theorem: under what conditions does each apply, and how is Fermat's theorem a special case of Euler's?

  3. If you need to find gcdโก(252,198)\gcd(252, 198), which method would be more efficient: prime factorization or the Euclidean algorithm? Trace through the steps of your chosen method.

  4. Why does the Chinese Remainder Theorem require the moduli to be pairwise coprime? What would go wrong if gcdโก(m1,m2)>1\gcd(m_1, m_2) > 1?

  5. Given that aโ‰กb(modm)a \equiv b \pmod{m} and cโ‰กd(modm)c \equiv d \pmod{m}, explain why you can conclude acโ‰กbd(modm)ac \equiv bd \pmod{m} but cannot always conclude acโ‰กbd(modm)\frac{a}{c} \equiv \frac{b}{d} \pmod{m}.

Key Number Theory Concepts to Know for Discrete Mathematics