Uploaded February 2022 | Updated September 2026, 1 week ago
π» Code: thecodingtrain.com/challenges/167-prime-spiral
β¨ Watch the uncut version on Nebula! nebula.tv/videos/codingtrain-the-prime-spiral-uncut-version-coding-challenge-167
β¨ Watch this video ad-free on Nebula! nebula.tv/videos/codingtrain-the-prime-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.
p5.js Web Editor Sketches:
πΉοΈ Prime (Ulam) Spiral: editor.p5js.org/codingtrain/sketches/0Ud-XsaYb
πΉοΈ Number Spiral: editor.p5js.org/codingtrain/sketches/Zs65bV-Al
πΉοΈ Prime vs Random Spiral: editor.p5js.org/codingtrain/sketches/3np1hBlXD
πΉοΈ Shapes & Color: editor.p5js.org/codingtrain/sketches/mCvvSKpZ5
πΉοΈ Incorporating 3D: editor.p5js.org/codingtrain/sketches/-eX078HZ5
π₯ Previous video: youtu.be/55iwMYv8tGI?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Next video: youtu.be/NJCiUVGiNyA?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ All videos: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References:
πΊ CodingTrainChooChoo on Twitch: twitch.tv/codingtrainchoochoo
2οΈβ£ Mathematical Games: The remarkable lore of the prime numbers (1964): scientificamerican.com/article/mathematical-games-1964-03
π An Observation on the Distribution of Primes, M. Stein and S. M. Ulam: doi.org/10.2307/2314055
π Prime Numbers (Wikipedia): en.wikipedia.org/wiki/Prime_number
π List of Prime Numbers: en.wikipedia.org/wiki/List_of_prime_numbers
π Download Processing 4: processing.org/download
Videos:
π₯ Prime Spirals: youtube.com/watch?v=iFuR97YcSLM
πΆ Processing Theme Selector music by twitter.com/WillFromAmerica
Timestamps:
0:00 Welcome! Choo choo!
0:23 History of the 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 & examples
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
π Website: thecodingtrain.com
πΎ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
π© Suggest Topics: github.com/CodingTrain/Suggestion-Box
π‘ GitHub: github.com/CodingTrain
π¬ Discord: thecodingtrain.com/discord
π Membership: youtube.com/thecodingtrain/join
π Store: standard.tv/codingtrain
ποΈ Twitter: twitter.com/thecodingtrain
πΈ Instagram: instagram.com/the.coding.train
π₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: p5js.org
π p5.js Web Editor: editor.p5js.org
π Processing: processing.org
π Code of Conduct: github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/new
#primenumbers #p5js #javascript
π» Code: thecodingtrain.com/challenges/167-prime-spiral
β¨ Watch the uncut version on Nebula! nebula.tv/videos/codingtrain-the-prime-spiral-uncut-version-coding-challenge-167
β¨ Watch this video ad-free on Nebula! nebula.tv/videos/codingtrain-the-prime-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.
p5.js Web Editor Sketches:
πΉοΈ Prime (Ulam) Spiral: editor.p5js.org/codingtrain/sketches/0Ud-XsaYb
πΉοΈ Number Spiral: editor.p5js.org/codingtrain/sketches/Zs65bV-Al
πΉοΈ Prime vs Random Spiral: editor.p5js.org/codingtrain/sketches/3np1hBlXD
πΉοΈ Shapes & Color: editor.p5js.org/codingtrain/sketches/mCvvSKpZ5
πΉοΈ Incorporating 3D: editor.p5js.org/codingtrain/sketches/-eX078HZ5
π₯ Previous video: youtu.be/55iwMYv8tGI?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Next video: youtu.be/NJCiUVGiNyA?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ All videos: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
References:
πΊ CodingTrainChooChoo on Twitch: twitch.tv/codingtrainchoochoo
2οΈβ£ Mathematical Games: The remarkable lore of the prime numbers (1964): scientificamerican.com/article/mathematical-games-1964-03
π An Observation on the Distribution of Primes, M. Stein and S. M. Ulam: doi.org/10.2307/2314055
π Prime Numbers (Wikipedia): en.wikipedia.org/wiki/Prime_number
π List of Prime Numbers: en.wikipedia.org/wiki/List_of_prime_numbers
π Download Processing 4: processing.org/download
Videos:
π₯ Prime Spirals: youtube.com/watch?v=iFuR97YcSLM
πΆ Processing Theme Selector music by twitter.com/WillFromAmerica
Timestamps:
0:00 Welcome! Choo choo!
0:23 History of the 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 & examples
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
π Website: thecodingtrain.com
πΎ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
π© Suggest Topics: github.com/CodingTrain/Suggestion-Box
π‘ GitHub: github.com/CodingTrain
π¬ Discord: thecodingtrain.com/discord
π Membership: youtube.com/thecodingtrain/join
π Store: standard.tv/codingtrain
ποΈ Twitter: twitter.com/thecodingtrain
πΈ Instagram: instagram.com/the.coding.train
π₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: p5js.org
π p5.js Web Editor: editor.p5js.org
π Processing: processing.org
π Code of Conduct: github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/new
#primenumbers #p5js #javascript










![Playing YOUR Versions of the Apple ][ Snake Game! - Showcase 1 #creativecoding #programming #shorts
For the first episode of this series, I react to a few submissions from the AppleSoft BASIC Snake Game Passenger Showcase. Next stop: Wave Function Collapse Showcase arriving next week!
π₯ BASIC Snake Game: https://youtu.be/7r83N3c2kPw
π¨ https://thecodingtrain.com/challenges/173-snake-applesoft-basic
π₯ WFC: https://youtu.be/rI_y2GAlQFM
π¨ https://thecodingtrain.com/challenges/171-wave-function-collapse
To learn how to submit yours, visit The Coding Train website and follow the guide: https://thecodingtrain.com/guides/passenger-showcase-guide
π Website: http://thecodingtrain.com/
πΎ Share Your Creation! https://thecodingtrain.com/Guides/community-contribution-guide.html
π© Suggest Topics: https://github.com/CodingTrain/Rainbow-Topics
π‘ GitHub: https://github.com/CodingTrain
π¬ Discord: https://discord.gg/hPuGy2g
π Membership: http://youtube.com/thecodingtrain/join
π Store: https://standard.tv/codingtrain
π Books: https://www.amazon.com/shop/thecodingtrain
ποΈ Twitter: https://twitter.com/thecodingtrain
πΈ Instagram: https://www.instagram.com/the.coding.train/
π₯ Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: https://p5js.org
π p5.js Web Editor: https://editor.p5js.org/
π Processing: https://processing.org
π Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct Playing YOUR Versions of the Apple ][ Snake Game! - Showcase 1 #creativecoding #programming #shorts](https://i.ytimg.com/vi/fAyGmUeNIFQ/mqdefault.jpg)