Expand description
Prime number distribution, sieves, and rendering utilities.
Structs§
- Prime
Distribution Renderer - Maps primes to glyph positions, sizes, and colors for engine rendering.
- Prime
Glyph - A renderable glyph descriptor for a prime.
- Sacks
Spiral - Sacks spiral: polar plot where integer n is at angle sqrt(n) * 2*pi, radius sqrt(n).
- Ulam
Spiral - Ulam spiral: maps positive integers to a 2D grid position via a spiral walk, highlighting prime positions.
Functions§
- is_
prime - Primality test. Uses trial division for small n, Miller-Rabin for large n.
- nth_
prime - Returns the n-th prime (1-indexed: nth_prime(1) == 2).
- prime_
counting - Prime counting function pi(x): number of primes <= x.
- prime_
factorization - Prime factorization of n, returned as sorted (prime, exponent) pairs.
- prime_
gaps - Gaps between consecutive primes up to
limit. - sieve_
of_ eratosthenes - Classic sieve of Eratosthenes returning all primes up to
limit. - twin_
primes - Twin prime pairs (p, p+2) up to
limit.