Sieving primes and the Ulam spiral
The Sieve of Eratosthenes (≈240 BCE) marks all multiples of 2, 3, 5, … in sequence; the unmarked numbers are prime, in O(N log log N) time — remarkably fast for one of the oldest algorithms in existence. Stanisław Ulam discovered his eponymous spiral by accident in 1963, doodling during a conference talk: write 1, 2, 3, … in an outward spiral on a square grid, mark the primes, and unmistakable diagonal lines appear. The diagonals correspond to quadratic polynomials of the form n² + n + 41 (the Hardy-Ramanujan formula), which produce a disproportionate density of primes for small n — visual evidence that prime distribution is not purely random. A polar variant, the Sacks spiral, places integer n at angle θ = 2π√n and makes the quasi-periodicity of primes even clearer, with primes forming striking radial rays and arches.
Fibonacci Spirals and the Ulam Spiral
The Fibonacci sequence is defined as F(n) = F(n-1) + F(n-2), where F(0) = 0 and F(1) = 1. This sequence appears in many natural settings, including the arrangement of leaves on a stem, the spirals of galaxies, and the branching of trees.
The golden ratio (φ ≈ 1.618) is closely related to the Fibonacci sequence. As you move further along the sequence, the ratio between consecutive numbers approaches φ. For example: F(2)/F(1) = 1.5, F(3)/F(2) = 1.667, F(4)/F(3) = 1.615, and so on.
The Ulam Spiral is a visual representation of the Fibonacci sequence and the golden ratio. It's created by plotting points on a plane where each point (x, y) represents a pair of consecutive Fibonacci numbers F(n) and F(n+1). The spiral emerges as these points are connected with straight lines.
The Ulam Spiral is often used to illustrate the distribution of prime numbers. Points representing primes are typically marked in a different color, revealing patterns and relationships between primes and the Fibonacci sequence.
Fibonacci, the golden ratio, and sunflower spirals
The Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21, … (F(n) = F(n-1) + F(n-2)) has consecutive-term ratios converging to the golden ratio φ = (1+√5)/2 ≈ 1.618. Sunflower seeds, pine cone scales and daisy petals arrange themselves in two interlocking families of spirals whose counts are almost always consecutive Fibonacci numbers (13 and 21, 34 and 55, …), because each successive seed is placed at a fixed angular increment equal to the golden angle: 360° × (1 − 1/φ) ≈ 137.508°. Because φ's continued-fraction representation [1;1,1,1,…] converges as slowly as possible, no seed ever lands on the same ray as an earlier one — the densest possible packing.
Sieve of Eratosthenes: O(N log log N) time, O(N) space π(x) ~ x / ln(x) (Prime Number Theorem) φ = (1 + √5) / 2 = 1.6180339887… (golden ratio) golden angle = 360° × (1 − 1/φ) ≈ 137.508°
Frequently asked questions
Що таке спіраль Улама і чому числа-прості утворюють діагоналі?
Станіслав Улам виявив цю спіраль у 1963 році, записуючи цілі числа 1, 2, 3… у формі спіралі, що розширюється на квадратійній сітці та відзначаючи прості числа. Діагоналі відповідають квадратичним поліномам виду n² + n + 41 (формула Гарді-Рамануджана), які створюють непропорційну щільність простих чисел для невеликих значень n, що натякає на те, що розподіл простих чисел не є повністю випадковим.
Чому соняшники використовують золотий кут для розміщення насіння?
Кожне наступне зерно розташовується під фіксованою кутовою відстанню від попереднього. Золотий кут, 360° × (1 − 1/φ) ≈ 137.508°, є ірраціональним у найбільш екстремальному сенсі, тому зерна ніколи не падають точно на один і той самий луч, що раніше – це максимізує однорідність упаковки та створює дві сім'ї спіралей, чисельники яких є послідовними числами Фібоначчі, такі як 34 і 55.
Що таке гіпотеза Рімана і як вона пов’язана з простими числами?
Функція Рімана ζ(s) кодує точний розподіл простих чисел через її нетривіальні нулі, комплексні числа ρ, де ζ(ρ) = 0. Гіпотеза Рімана, сформульована в 1859 році, передбачає, що кожен нетривіальний нуль має дійсну частину рівно 1/2. Якщо вона правдива, це дало б найточніший можливий ліміт на те, наскільки відхиляються числа π(x) від свого гладкого наближення — її досі не розв’язано і це одна з проблем Millennium Prize Problems.
Спробуйте наживо
Усе, що вище, працює прямо у вашому браузері — відкрийте the simulation і змінюйте параметри під час роботи. Нічого не встановлюється, нічого не завантажується на сервер, уся модель живе в одній вкладці.
▶ Відкрити симуляцію the simulation