Ulam's spiral

Marmilo

Retired Staff / Scale Inspector
TEAM HAWK
Atlas
Fly me to the Moon
Under Pressure
Copycat
Registered
MOTY 2022
#1
There was a mathematian called Ulam, and he discovered that if you write out numbers on a square spiral like this (or bigger):

4 3 2
5 0 1
7 8 9

now you leave only prime numbers

3 2
5
7

now replace them with something like an asterisk

* *
*
*
So, I wrote a c++ program that generates them. For a square of size 8, it looks like this:

* *
*
* * *
* * * * *
*
* *
* *
* *

You can see some lines forming now

And after figuring out how to zoom out the terminal I can do this:
2022-12-12-211416_1920x1080_scrot.png

that's 300x300 tiles.
What do you guys think?
 
Last edited:

Marmilo

Retired Staff / Scale Inspector
TEAM HAWK
Atlas
Fly me to the Moon
Under Pressure
Copycat
Registered
MOTY 2022
#3
Huh, my spaces got deleted. Rip
 

Marmilo

Retired Staff / Scale Inspector
TEAM HAWK
Atlas
Fly me to the Moon
Under Pressure
Copycat
Registered
MOTY 2022
#4
This is how it should look:
2022-12-12-222253_1920x1080_scrot.png
 

Altaïr

Space Stig, Master of gravity
Staff member
Head Moderator
Team Kolibri
Modder
TEAM HAWK
Atlas
Deja Vu
Under Pressure
Forum Legend
#5
Oh, the Ulam spiral, interesting. Just to be curious, did you try to run your program for a larger square size? But I suppose the resources needed become prohibitive at some point. How do you determine if a number is a prime number? The sieve of Eratosthenes I suppose?
 

Marmilo

Retired Staff / Scale Inspector
TEAM HAWK
Atlas
Fly me to the Moon
Under Pressure
Copycat
Registered
MOTY 2022
#6
Oh, the Ulam spiral, interesting. Just to be curious, did you try to run your program for a larger square size? But I suppose the resources needed become prohibitive at some point. How do you determine if a number is a prime number? The sieve of Eratosthenes I suppose?
Yup, Erastothenes' sieve. Maximum size I tried was 330 i believe.