1. Home
  2. Explore
  3. Mathematics
  4. Number Theory Introduction

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Number Theory Introduction

Number Theory: Key Concepts and Applications

What is Number Theory?

Number theory is the branch of mathematics primarily concerned with the positive integers (counting numbers: 1, 2, 3, …). It studies their properties: whether they are odd or even, perfect squares or cubes, divisible by a given number, and many other characteristics. The most important objects in number theory are the prime numbers — numbers whose only factors are 1 and themselves. Primes are the building blocks of the subject, analogous to atoms in chemistry. For example, 11, 13, 17, and 19 are primes; 15 and 18 are not (15 = 3×5, 18 = 2×3×3). Some numbers that look prime (like 91 = 7×13 and 323 = 17×19) are not, so determining primality is not always easy.

Key questions in number theory include:

  • Is a given number prime?

  • Are numbers composed entirely of ones (like 1111) ever perfect squares?

  • Problems arising from the calendar (e.g., which years have five Sundays in February?).

  • Applications to right-angle triangles (Pythagorean triples) and the construction of regular polygons.

  • Practical applications: card shuffling and cryptography (credit card security), relying on prime number results dating back to the 18th century.

Definition: Number theory studies the positive integers and their properties, with primes playing a central role.


Prime Numbers

Sieve of Eratosthenes

The ancient Greek method for finding primes up to a given limit works by listing all numbers, then crossing out multiples of 2, 3, 5, 7, etc. The numbers not crossed out are primes. For numbers up to 100, the primes are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.

Why 1 Is Not a Prime

The Fundamental Theorem of Arithmetic states that every positive integer can be expressed uniquely (up to order) as a product of primes. If 1 were considered prime, uniqueness would break (e.g., 6 = 2×3 = 2×3×1 = 2×3×1×1). Therefore, 1 is excluded from the primes.

Infinitude of Primes (Euclid’s Proof)

Euclid's Elements provides a geometric argument that the list of primes never ends. In modern language:

Assume there are only finitely many primes: p1,p2,p3,…,pnp_1, p_2, p_3, \dots, p_np1​,p2​,p3​,…,pn​. Construct the number

N=p1×p2×p3×⋯×pn+1.N = p_1 \times p_2 \times p_3 \times \cdots \times p_n + 1.N=p1​×p2​×p3​×⋯×pn​+1.

Each prime pip_ipi​ divides the product p1p2⋯pnp_1 p_2 \cdots p_np1​p2​⋯pn​, so it cannot divide NNN (since pip_ipi​ would have to divide 1, which is impossible). Therefore NNN is either prime itself or has a prime factor not among the pip_ipi​. In either case, a new prime exists, contradicting the assumption. Hence there are infinitely many primes.

Note: NNN may be prime (e.g., using primes 2,3,5,7 gives N=211N=211N=211, prime) or composite (e.g., using primes up to 13 gives N=30031=59×509N=30031 = 59 \times 509N=30031=59×509, introducing two new primes).

Primes of the Form 4n+14n+14n+1 and 4n+34n+34n+3

Euclid's proof can be adapted to show there are infinitely many primes of the form 4n+34n+34n+3 (e.g., 3, 7, 11). Similarly, there are infinitely many primes of the form 4n+14n+14n+1 (e.g., 5, 13, 17). Numbers of the form 4n+24n+24n+2 are even and cannot be prime except 2 itself.

Dirichlet’s Theorem (1837): For any integers aaa and bbb with gcd⁡(a,b)=1\gcd(a,b)=1gcd(a,b)=1, there are infinitely many primes of the form an+ban+ban+b. This includes the cases 4n+14n+14n+1 and 4n+34n+34n+3, and also implies infinitely many primes ending in 1, 3, 7, or 9 (take a=10a=10a=10, b=1,3,7,9b=1,3,7,9b=1,3,7,9).

Mersenne Primes

Numbers of the form 2n−12^n - 12n−1 are called Mersenne numbers, named after Marin Mersenne. Some Mersenne numbers are prime (e.g., 22−1=32^2-1=322−1=3, 23−1=72^3-1=723−1=7, 25−1=312^5-1=3125−1=31, 27−1=1272^7-1=12727−1=127). However, 211−1=2047=23×892^{11}-1 = 2047 = 23 \times 89211−1=2047=23×89 is composite. In general:

  • If nnn is composite, then 2n−12^n - 12n−1 is also composite.

  • If nnn is prime, 2n−12^n - 12n−1 may or may not be prime (no simple rule).

Mersenne primes are important for finding large primes (the 17 most recently discovered primes are Mersenne primes, including 282,589,933−12^{82,589,933} - 1282,589,933−1 with nearly 25 million digits, discovered in December 2018).

Perfect Numbers

A perfect number is a positive integer equal to the sum of its proper divisors (factors excluding itself). Examples:

  • 6: factors 1,2,3 sum to 6.

  • 28: factors 1,2,4,7,14 sum to 28.

  • 496, 8128 are also perfect.

Euclid proved that if 2n−12^n - 12n−1 is prime (a Mersenne prime), then 2n−1(2n−1)2^{n-1}(2^n - 1)2n−1(2n−1) is a perfect number. Over 2000 years later, Euler proved that every even perfect number has this form. The existence of odd perfect numbers remains unknown; if any exist, they must exceed 10150010^{1500}101500.

Fermat Numbers

Numbers of the form 22n+12^{2^n} + 122n+1 are called Fermat numbers. Fermat conjectured that all such numbers are prime. The first few (3,5,17,257,655373, 5, 17, 257, 655373,5,17,257,65537) are indeed prime. But Euler showed that 225+1=4,294,967,2972^{2^5} + 1 = 4,294,967,297225+1=4,294,967,297 is divisible by 641 (hence composite). No further Fermat primes have been found; all larger Fermat numbers are known to be composite. Despite this, Fermat primes appear in an unexpected geometric context: the construction of regular polygons.


Construction of Regular Polygons

The ancient Greeks constructed regular polygons (equal sides and angles) using only an unmarked ruler and compasses. They succeeded for triangles (3 sides), squares (4), pentagons (5), hexagons (6), and by doubling sides, polygons with 2n2^n2n sides. By combining constructions, they also built a 15-sided polygon. However, polygons with 7, 9, 11, 13, 14, 18, or 19 sides were not constructible by those means.

Gauss’s Theorem (age 18): A regular polygon with nnn sides is constructible with ruler and compass if and only if nnn is the product of a power of 2 and distinct Fermat primes.

The known Fermat primes are 3, 5, 17, 257, 65537.
Examples of constructible nnn: 30 (2×3×5), 32 (252^525), 34 (2×17), 40 (23×52^3×523×5).
Non-constructible nnn: 35 (5×7, 7 not allowed), 36 (22×322^2×3^222×32, 3 repeated), 37 (not a Fermat prime), 100 (factor 5 appears twice). Thus a 100-sided regular polygon cannot be constructed with ruler and compasses.


Perfect Squares

Properties of Perfect Squares

The first ten squares: 1, 4, 9, 16, 25, 36, 49, 64, 81, 100.
Observations:

  • No square ends in 2, 3, 7, or 8.

  • Sums of consecutive odd numbers give squares: 1=121 = 1^21=12, 1+3=221+3 = 2^21+3=22, 1+3+5=321+3+5 = 3^21+3+5=32, etc. This can be shown geometrically by arranging odd numbers as L-shaped gnomon around a square.

  • Every square is either a multiple of 4 or one more than a multiple of 4. No square is 4n+24n+24n+2 or 4n+34n+34n+3.

  • If nnn is odd, n2≡1(mod8)n^2 \equiv 1 \pmod{8}n2≡1(mod8) (one more than a multiple of 8). This can be seen algebraically: n=2k+1⇒n2=4k(k+1)+1n=2k+1 \Rightarrow n^2 = 4k(k+1)+1n=2k+1⇒n2=4k(k+1)+1, and k(k+1)k(k+1)k(k+1) is even, so n2=8m+1n^2 = 8m+1n2=8m+1.

Numbers made entirely of ones (11, 111, 1111, …) are all 3mod  43 \mod 43mod4, so they cannot be perfect squares.

Pythagorean Triples

A right-angle triangle with integer side lengths satisfies a2+b2=c2a^2 + b^2 = c^2a2+b2=c2 (Pythagorean theorem). Examples: (3,4,5), (5,12,13), (8,15,17). Scaling yields infinitely many, but the primitive triples (with no common factor) are the focus.

Using algebraic arguments, all primitive triples with aaa odd, bbb even can be generated by:

a=x2−y2,b=2xy,c=x2+y2,a = x^2 - y^2,\quad b = 2xy,\quad c = x^2 + y^2,a=x2−y2,b=2xy,c=x2+y2,

where x>y>0x > y > 0x>y>0, gcd⁡(x,y)=1\gcd(x,y)=1gcd(x,y)=1, and one of x,yx,yx,y is even.
Examples:

  • x=2,y=1x=2, y=1x=2,y=1: gives (3,4,5).

  • x=3,y=2x=3, y=2x=3,y=2: gives (5,12,13).

  • x=5,y=2x=5, y=2x=5,y=2: gives (21,20,29).

These formulas produce all Pythagorean triples. For example, finding all triangles with a side of length 29: either 29 is ccc (giving x=5,y=2x=5, y=2x=5,y=2 leading to (21,20,29)) or 29 is aaa (giving x=15,y=14x=15, y=14x=15,y=14 leading to (29,420,421)).

Sums of Two Squares

A number can be written as the sum of two squares only if it is of the form 4n4n4n or 4n+14n+14n+1 (since squares are 000 or 1mod  41 \mod 41mod4). For primes, Fermat’s theorem (proved by Euler) states: every prime ppp of the form 4n+14n+14n+1 can be written as a sum of two squares in exactly one way. Examples:

  • 5=12+225 = 1^2 + 2^25=12+22

  • 13=22+3213 = 2^2 + 3^213=22+32

  • 17=12+4217 = 1^2 + 4^217=12+42

  • 29=22+5229 = 2^2 + 5^229=22+52

  • 41=42+5241 = 4^2 + 5^241=42+52

Fermat’s Last Theorem

The equation xn+yn=znx^n + y^n = z^nxn+yn=zn has no positive integer solutions for n>2n > 2n>2. Fermat claimed a proof (the “margin too small to contain it”), but it remained unproved until 1995 when Andrew Wiles proved the theorem using deep methods. For n=4n=4n=4, Fermat himself gave a proof using the method of infinite descent.


Modular Arithmetic (Clock Arithmetic)

Basics

Modular arithmetic, introduced by Gauss, involves numbers “wrapping around” after reaching a modulus. For a 12-hour clock: 9 + 6 = 3 (mod 12). It is convenient to write 0 for 12, so 8 + 4 = 0 (mod 12).
General definition: a≡b(modn)a \equiv b \pmod{n}a≡b(modn) if nnn divides a−ba-ba−b (equivalently, aaa and bbb leave the same remainder when divided by nnn).

The same idea applies to days of the week (mod 7). Numbering Sunday=0, Monday=1, …, Saturday=6: Thursday (4) + 4 days = Monday (1 mod 7); Saturday (6) + 3 days = Tuesday (2 mod 7).

Calendar Calculations

John Conway and Lewis Carroll (Charles Dodgson) devised methods to find the day of the week for any date. Carroll's method involves four numbers, added modulo 7:

  1. Century number: Divide the first two digits of the year by 4, subtract remainder from 3, double the result.

  2. Year number: Divide the last two digits of the year by 12; add the quotient, remainder, and the number of times 4 divides the remainder.

  3. Month number: Use a table (e.g., January=0, February=3, March=3, April=6, May=1, June=4, July=6, August=2, September=5, October=0, November=3, December=5).

  4. Day number: Simply the day of the month.

Sum these four numbers, take mod 7 (0=Sunday, 1=Monday, …, 6=Saturday).
Example for 28 September 2020:

  • Century (20): 20/4 remainder 0 → (3-0)×2 = 6.

  • Year (20): 20/12 = 1 remainder 8; 4 divides 8 twice; sum = 1+8+2 = 11.

  • Month (September): 5.

  • Day: 28.

  • Total = 6+11+5+28 = 50; 50 mod 7 = 1 → Monday (correct).

For the problem of when February has five Sundays: February must have 29 days (leap year). Using a known starting day (e.g., 1 Jan 2001 was Monday), one finds that 1 Feb 2004 was Sunday, so 2004 works. Because the day cycle repeats every 28 years (due to leap years), the other years in the 21st century are 2032, 2060, 2088.


Fermat’s Little Theorem and Generalizations

Fermat’s Little Theorem

If ppp is a prime and aaa is any integer, then ap≡a(modp)a^p \equiv a \pmod{p}ap≡a(modp). Equivalently, if ppp does not divide aaa, then ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}ap−1≡1(modp).
Example: 837−88^{37} - 8837−8 is divisible by 37. Also 252≡1(mod53)2^{52} \equiv 1 \pmod{53}252≡1(mod53).

Proof by counting necklaces: Consider necklaces with ppp beads and aaa colors, using at least two colors. The number of strings of ppp beads with aaa colors is apa^pap; subtract the aaa monochromatic strings gives ap−aa^p - aap−a. When forming necklaces (rotations considered identical), each necklace corresponds to exactly ppp strings (because ppp is prime, all rotations are distinct unless the string is monochromatic). Hence the number of distinct necklaces is (ap−a)/p(a^p - a)/p(ap−a)/p, which must be an integer. Therefore ppp divides ap−aa^p - aap−a.

Application: Card Shuffling

A perfect riffle shuffle of 52 cards moves the card from position xxx to position 2x2x2x (mod 53). After nnn shuffles, a card moves to 2nx2^n x2nx (mod 53). The deck returns to original order when 2n≡1(mod53)2^n \equiv 1 \pmod{53}2n≡1(mod53). By Fermat’s little theorem, 252≡1(mod53)2^{52} \equiv 1 \pmod{53}252≡1(mod53), and checking smaller divisors of 52 shows that 52 is the smallest such nnn. Hence 52 shuffles restore a 52‑card deck.

For a 54‑card deck (with two jokers, so 54 cards), we work modulo 55. Since 55=5×1155 = 5 \times 1155=5×11, we need 2n≡1(mod55)2^n \equiv 1 \pmod{55}2n≡1(mod55). Using Fermat’s theorem for 5 and 11: 24≡1(mod5)2^4 \equiv 1 \pmod{5}24≡1(mod5) and 210≡1(mod11)2^{10} \equiv 1 \pmod{11}210≡1(mod11). Raising the first to the 5th power gives 220≡1(mod5)2^{20} \equiv 1 \pmod{5}220≡1(mod5); squaring the second gives 220≡1(mod11)2^{20} \equiv 1 \pmod{11}220≡1(mod11). Thus 220≡1(mod55)2^{20} \equiv 1 \pmod{55}220≡1(mod55). No smaller nnn works, so the answer is 20 shuffles.

Euler’s Theorem (Generalization)

For composite moduli, we use Euler’s totient function ϕ(n)\phi(n)ϕ(n): the number of positive integers less than or equal to nnn that are coprime to nnn.

  • For prime ppp: ϕ(p)=p−1\phi(p) = p-1ϕ(p)=p−1.

  • For product of distinct primes ppp and qqq: ϕ(pq)=(p−1)(q−1)\phi(pq) = (p-1)(q-1)ϕ(pq)=(p−1)(q−1).

  • Example: ϕ(10)=4\phi(10) = 4ϕ(10)=4 (numbers 1,3,7,9); ϕ(12)=4\phi(12) = 4ϕ(12)=4 (1,5,7,11).

Euler’s Theorem: If gcd⁡(a,n)=1\gcd(a,n)=1gcd(a,n)=1, then aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod{n}aϕ(n)≡1(modn).

When nnn is prime, this reduces to Fermat’s little theorem.


RSA Cryptography

RSA (Rivest, Shamir, Adleman) is a public-key cryptosystem that secures credit card transactions. It relies on the difficulty of factoring large numbers.

Key generation (Bob):

  1. Choose two large primes ppp and qqq (e.g., 29 and 37).

  2. Compute N=pqN = pqN=pq (e.g., 107310731073).

  3. Compute ϕ(N)=(p−1)(q−1)\phi(N) = (p-1)(q-1)ϕ(N)=(p−1)(q−1) (e.g., 28×36=100828 \times 36 = 100828×36=1008).

  4. Choose an encryption exponent eee such that gcd⁡(e,ϕ(N))=1\gcd(e, \phi(N)) = 1gcd(e,ϕ(N))=1 (e.g., e=11e=11e=11).

  5. Publish the public key (N,e)(N, e)(N,e); keep ppp, qqq, ϕ(N)\phi(N)ϕ(N) private.

Encryption (Alice):

  1. Convert her message to a number MMM (with M<NM < NM<N).

  2. Compute ciphertext C=Memod  NC = M^e \mod NC=MemodN.

  3. Send CCC to Bob.

Decryption (Bob):

  1. Find the decryption exponent ddd such that ed≡1(modϕ(N))e d \equiv 1 \pmod{\phi(N)}ed≡1(modϕ(N)) (e.g., 11×275≡1(mod1008)11 \times 275 \equiv 1 \pmod{1008}11×275≡1(mod1008), so d=275d=275d=275).

  2. Compute M=Cdmod  NM = C^d \mod NM=CdmodN (by Euler’s theorem, Med≡M(modN)M^{e d} \equiv M \pmod{N}Med≡M(modN)).

The security comes from the fact that multiplying two large primes is easy, but factoring their product back into ppp and qqq is computationally infeasible for sufficiently large primes. Thus, given only NNN and eee, an eavesdropper cannot determine ddd without factoring NNN.

The entire process relies on:

  • The one-way nature of multiplication vs. factoring.

  • Euler’s theorem to guarantee decryption works.

So when you use a credit card online, RSA cryptography, rooted in number theory from the 18th century, protects your data.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent