Number theory
Explore the hidden structure of integers. Visualize prime factorizations, Euler's totient function, divisor sums, and modular arithmetic. Watch the sieve of Eratosthenes eliminate composites, and see how modular multiplication on a circle creates star polygons and cardioid-like envelopes.
φ(n) = n ∏(1 − 1/p) σ(n) = ∑d|n d a·b ≡ c (mod n)
The sieve of Eratosthenes
The oldest known algorithm for finding primes, attributed to Eratosthenes of Cyrene (~240 BCE). Start with all integers from 2 to N. The first unmarked number is prime — mark all its multiples as composite. Move to the next unmarked number and repeat. What remains are exactly the primes up to N.
Euler’s totient function
φ(n) counts how many integers from 1 to n are coprime to n. For a prime p, φ(p) = p − 1. For prime powers, φ(pᵈ) = pᵈ − pᵈ⁄₁. The totient is multiplicative: φ(ab) = φ(a)φ(b) when gcd(a,b) = 1. It appears in Euler’s theorem: aⁿ ≡ a (mod n) when gcd(a,n) = 1.
Modular multiplication circles
Place n points equally spaced on a circle, labeled 0 to n−1. For each point i, draw a line to (i × m) mod n, where m is the multiplier. When m = 2, you get a cardioid. When m = 3, a nephroid. Different multipliers produce different families of curves — all from straight lines and modular arithmetic.
Divisor functions
σ(n) is the sum of all divisors of n. τ(n) (or d(n)) is the number of divisors. A number is perfect when σ(n) = 2n, abundant when σ(n) > 2n, and deficient when σ(n) < 2n. Only six perfect numbers were known before computers: 6, 28, 496, 8128, 33550336, and 8589869056.