Primearium Lab · residue space

Primality as geometry

Write every number as its remainders: (n mod 5, n mod 7) is a point on a torus. Numbers walk a single thread around it. Multiples hit the glowing walls; primes slip through every wall.

Build the walls

Torus
Walls (dimensions)

Each prime is one dimension of residue space and one wall n ≡ 0 (mod p). Outlined primes are needed for the current range: p² ≤ N.

Free space
First impostor
Primes on the torus

Tip: tap a cell of the torus to see which numbers live there.

Why primes slip through

Take any number and write down its remainders: 137 → (137 mod 2, 137 mod 3, 137 mod 5, 137 mod 7) = (1, 2, 2, 4). These remainders are coordinates. Each prime gives one more axis, so every number becomes a point in a many-dimensional space.

A remainder of 0 means "divisible". So for every prime p there is a whole wall of points with coordinate 0 on that axis. A composite number always stands on at least one wall - the wall of its smallest prime factor.

Two axes already make a torus: n mod 5 goes around the big circle, n mod 7 around the tube. Because 5 and 7 share no factor, the numbers 0 to 34 land on 35 different cells, then the pattern repeats - the Chinese Remainder Theorem. Adding a wall is exactly one step of the sieve of Eratosthenes.

Proven A whole number n > 1 is prime if and only if none of its coordinates for the primes p ≤ √n is zero. This is trial division: if n = a·b with 1 < a ≤ b, then a ≤ √n, so the smallest prime factor of n is at most √n.

The fingerprint of a number

Type any whole number. Each dial shows one coordinate, n mod p. A dial pointing at the red mark reads 0: that prime divides n. Only dials with p ≤ √n are needed (bright); the others are dimmed.

For mathematicians

Exact statements, what is proven, what was measured up to 10⁷, references.
  1. Proven Trial division. n > 1 is prime ⇔ n mod p ≠ 0 for every prime p ≤ √n. With walls for the primes p₁ < … < p_k, every free n with p_k < n < p_{k+1}² is prime, and the first free composite is p_{k+1}² (shown above as the first impostor).
  2. Proven Chinese Remainder Theorem. For pairwise coprime m₁, …, m_k the map n ↦ (n mod m₁, …, n mod m_k) is a ring isomorphism ℤ/Mℤ → ∏ ℤ/m_iℤ, M = ∏ m_i. On the torus a × b the thread n ↦ (2πn/a, 2πn/b) is the (a, b) torus knot and visits each of the ab cells once per period.
  3. Proven Free space. The points with no zero coordinate are the units of ℤ/Mℤ; their number is φ(M) = ∏(p − 1), their share ∏(1 − 1/p). For M = 2, 6, 30, 210, 2310, 30030: φ(M) = 1, 2, 8, 48, 480, 5760 (OEIS A005867). Euler: ∏_{p ≤ x}(1 − 1/p)⁻¹ ≥ Σ_{n ≤ x} 1/n, so the product tends to 0 - which forces infinitely many primes.
  4. Proven Dirichlet / PNT in progressions (de la Vallée Poussin, 1896). Primes are asymptotically equidistributed among the φ(M) free cells: π(x; M, r) ~ π(x)/φ(M) for gcd(r, M) = 1. This is why the golden spikes on the torus have about the same height.
  5. Proven Mertens' third theorem (1874). ∏_{p ≤ x} (1 − 1/p) ~ e^{−γ}/ln x. If the walls for p ≤ √N acted independently, N·∏_{p ≤ √N}(1 − 1/p) ~ 2e^{−γ}·N/ln N ≈ 1.1229·N/ln N numbers would survive - but π(N) ~ N/ln N. The walls are not independent at this scale: the error terms of the Legendre sieve (inclusion-exclusion) are too large to ignore.
  6. Proven Honesty. Nothing here is a new primality test or a formula for primes: it is the sieve of Eratosthenes and trial division written in coordinates. For large n, trial division needs about √n / ln √n dials, which is why practical tests (Miller-Rabin, ECPP, AKS) use other ideas.

Measured in your browser

Walls for∏(1 − 1/p) free n in [2, N]of them composite
Computing...

References

  • G. H. Hardy, E. M. Wright, An Introduction to the Theory of Numbers, 6th ed., Oxford 2008: CRT (ch. 5), Mertens' theorems (§22.7-22.8).
  • R. Crandall, C. Pomerance, Prime Numbers: A Computational Perspective, 2nd ed., Springer 2005: sieves and trial division (ch. 3).
  • F. Mertens, "Ein Beitrag zur analytischen Zahlentheorie", J. reine angew. Math. 78 (1874), 46-62.
  • OEIS: A002110 (primorials), A005867 (∏(p − 1)), A001248 (squares of primes), A000040 (primes) - oeis.org.
  • J. Friedlander, H. Iwaniec, Opera de Cribro, AMS 2010: sieve theory and its limits.