Ulam's spiral

Marmilo

Retired Staff / Scale Inspector
Veteran
Hot Stuff
Space Glider
Copycat
Atlas
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:

Altaïr

Space Stig, Master of gravity
Staff member
Head Moderator
Moderator
Veteran
Modder
Deja Vu
Hot Stuff
Swingin' on a Star
Atlas
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
Veteran
Hot Stuff
Space Glider
Copycat
Atlas
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.