Introduction
Why Number Theory?
Number theory is the study of integers — their structure, divisibility, and the primes that underlie all of arithmetic. It is one of the oldest branches of mathematics, yet it drives modern cryptography, error-correcting codes, and computer algorithms.
Despite its ancient roots, number theory is full of unsolved problems. Goldbach's conjecture, the Twin Prime Conjecture, and the Riemann Hypothesis remain open — yet the tools you will build in this course are used every day in software, cryptography, and mathematics.
How This Course Works
Each lesson introduces one concept, explains the mathematics, and asks you to implement it in pure Python — no libraries beyond the standard library. You will implement everything from scratch: GCD via the Euclidean algorithm, prime sieves, the Chinese Remainder Theorem, and full RSA encryption.
What You Will Build
- Divisibility — GCD, LCM, prime factorization, divisors, perfect numbers, and the Extended Euclidean Algorithm
- Prime Numbers — Primality testing, the Sieve of Eratosthenes, prime gaps, Goldbach's conjecture, and the prime counting function
- Modular Arithmetic — Modular addition, multiplication, fast exponentiation, Euler's totient, and the Chinese Remainder Theorem
- Applications — Fermat's Little Theorem, modular inverses, and a working RSA encryption system
Let's start with the most fundamental operation in all of number theory.