

Prompt
Copy the prompt and paste it into a new session in Claude Science. By default, Claude asks with a permission card before it runs code or installs packages.Prompt
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Compare the share of primes per diagonal on Ulam’s 1963 spiral of 1 to 40,401 against as many random odd numbers.


In 1963 the mathematician Stanisław Ulam, doodling during a long and boring talk, wrote the whole numbers in a square spiral and circled the primes. Recreate his picture. Find all primes up to 40,401 (= 201 × 201) with a sieve of Eratosthenes, and check that 1,229 of them are below 10,000. Write 1, 2, 3, … in a square spiral starting from the center, and mark the primes.
Are the diagonal streaks real, or is my eye fooling me? Draw the same picture with the same number of randomly chosen odd numbers. For every diagonal of odd numbers at least 100 cells long, in both directions, compute the share of marked cells, and compare its standard deviation and range in the 2 pictures.
Then highlight the numbers n² + n + 41 (Euler's polynomial). On this spiral about the first 40 values wind around the center, and from then on they run along 2 straight diagonals. How many of the first 100 are prime, and how many would you expect from typical odd numbers of that size? The first one that is not prime is n = 40, which gives 41 × 41. Which diagonals are rich in primes is predicted by a conjecture of Hardy and Littlewood (1923) that is still unproven: mention it, and describe the rich and poor diagonals without accounting for them. Walk me through your method at undergraduate level.
Was this page helpful?