## The Prime (Ulam) Spiral

Coding Challenge #167

Why do prime numbers show up as diagonals in a spiral? In this video, I create a visualization in JavaScript (p5.js) of the Ulam Spiral (aka Prime Spiral) named for Polish Mathematician Stanislav Ulan.

### Topics

- 0:00 - Welcome! Choo choo!
- 0:23 - History of Ulam Spiral
- 1:16 - Diagramming the Spiral
- 2:18 - Starting to Code
- 3:25 - How and when do I rotate?
- 4:25 - Coding the number spiral
- 7:00 - Debugging!
- 9:40 - Visualizing the spiral
- 12:22 - What is a prime number?
- 14:31 - Code to check if a number is prime.
- 18:57 - Marking primes in the spiral
- 19:40 - Porting to Processing (Java)!
- 22:46 - More references and examples

### Community Contributions

- My old and simple version of this challange
*by Ilya Sakharchuk*(Source Code) - Ulam Prime Spiral in green
*by Zane Dax (She/They)*(Source Code) - Hexagonal Ulam Prime Spiral
*by David van Deijk*(Source Code) - Ulam Prime Spiral in python with pylance
*by cenkt*(Source Code) - Ulam Prime Spiral in c++ on the command line
*by Shivansh Agrawal*(Source Code) - Easy Traversal of Ulam Prime Spiral in TypeScript
*by Jack Hodgkiss*(Source Code) - Musical Prime Spiral
*by Paul Selley*(Source Code) - Colourful Prime Spiral
*by Dipam Sen*(Source Code)

You can also add your own version! (See how)

### Links discussed in this coding challenge

### Videos discussed in this coding challenge

- Prime Spirals
*by Numberphile*