Reminds me of what I do when trying to look for structure in binary data. Print it to the screen in either bits or bites with word wrap enabled and drag the window around.
I spammed the columns from 1 to 402 (with 400 rows), and i saw some cool patterns. I can see a few nodes of clockwise rotation that converges into a single node from >200 columns that starts makes its way down the screen. Trippy.
Rotation effects of negative (whitespace) of moiré patterns from multiples of [2,3,5,7,11,13,17,19]. With each increment they are tilting at different 'rates' so the whole represents rotation of straight artifacts at several speeds at once.
Start with the vertical patterns; The vertical patterns happen for any composite number. Take the number 10 for example. Obviously numbers 10n + [0,2,4,6,8] are divisible by 2 and 10n + 5 are divisible by 5. So you can understand the vertical gaps in primality whenever you display a composite number. Multiple's of 10 is one you can probably grasp quickly but there's nothing special about base 10.
Now when you take a vertical pattern like you see with column width=10 and add one more to the column size (so make it 11) the pattern is now offset by one pixel on each row. This makes the vertical pattern render diagonally as each row is offset by a pixel.
So you get the patterns going between vertical and diagonal. This can get really interesting when you have a bunch of composite numbers in a row. Each composite number has it's own vertical pattern as described above. So 435 has gaps every 3rd and 5th number (and for other factors) since those will be multiple of 3 or 5. Now the next number, 436 rotates this pattern 45degrees since it offsets each row by 1 pixel. But.. 436 has it's own patterns, eg. every second number is a multiple of 2 when offset from 436 since 436 is even. So it has it's own vertical patterns but also shows the diagonals from gaps in 435.
Anyway these well understood gaps in primality give a galaxy appearance for this simple reason. You're seeing well understood vertical patterns shifting to render diagonally with new vertical patterns from alignment on the next number and repeat.
It'd be great to be able to plot only the primes that satisfy some simple (at first anyways) math operations. "Show me the primes that when (math operation) by (a set of values) equals (set of results). EG when (mult,div,squared) by (n1,n2...) equals (0,e^2, ...). Exploring for surprise patterns!
When choosing rows = 4000 and columns = 546, an interesting pattern emerges.
For all integers n ≥ 0, the ranges [243 + (n * 546)] to [249 + (n * 546)] inclusive appear to contain no prime numbers. Same with the ranges [297 + (n * 546)] to [303 + (n * 546)].
For both sets of ranges, the minimum gap between the closest neighbouring primes appears to be at least 10 (in decimal). Does anyone know of a number-theoretic explanation for this kind of pattern?
Nothing too surprising more or less same thing as all other vertical columns.
546=2*3*7*13 and all numbers in the range [242, 250] can be divided by one of those 4 primes same for [296, 304] . If x is divisor of a and b, then it will also divide a+n*b meaning you get an empty column. 2 and 3 already makes more than half the columns non primes, fill in the gaps with few more primes and you get the wide empty columns. If the width is multiple of many different small primes it's more likely to happen.
In a similar way 210=2*3*7*5 also gives wide empty columns (if you ignore ignore first row where 2,3,5,7 themselves are primes)
It helps if you think of it in terms of where the non primes are located instead of where the primes are. Multiples of 2, 3, 5 form a very regular pattern. Wrap it around in a grid and you get straight lines which are either straight vertical or slightly shifted depending on the divisors of width. Stack a couple of repetitive patterns and you still get a repetitive pattern. If the positions which are not primes form a regular pattern, the inverted image also forms recognizable pattern. Of course the primes don't form perfectly regular pattern and but most the visible repetition are result of small prime multiples.
Those are just columns that happen to share factors with 546 and happen to line up together. 546 is a very composite number (lots of factors!)
546n + 242 is always even
546n + 243 is always divisible by 3
546n + 244 is always even
546n + 255 is always divisible by 7.
Etc.
It's similar to how in base 10 you never see a prime ending in 0,2,4,6,8 or 5 since those numbers are clearly divisible by 2 or 5. In 546's case you have a lot of factors so even more gaps.
You also get the pattern appearing again since the number is even and the non-even factors repeat their pattern starting from the halfway point.
The reason behind that is similar to how all prime numbers above 2 are of the form 2n+1 since all other numbers are divisible by 2. Eg. all prime numbers >2 are odd.
In this case you're seeing the extension of this to include multiples of 3. That is, all prime numbers above 6 are of the form 6n+1 or 6n+5, all other numbers are either divisible by 2 or 3.
You can extend these patterns. Whenever you have a composite number you'll get periodic points where factors are known. Eg. to extend it one step further you could say all prime numbers above 30 are of the form 30n + [1,7,11,13,17,19,23,29], all others are divisible by 2, 3 or 5.
From this you can also quickly iterate towards to the prime number formula for the frequency of primes. eg. Only half of numbers above 2 can be prime (1/2), the rest are multiples of 2. Over 6 you have half of two thirds of numbers that can possibly be prime, the rest are multiples of 2 or 3. Over 30 only 1/2 x 2/3 x 4/5 could possibly be prime. etc. This converges to the prime number theorem!
Anyway if anyone ever expresses amazement that's good to see but mathematically it's well known. Prime numbers have patterns in their frequency, specifically where there's period multiples of factors there can't possibly be primes. It's the basis for prime number theory and patterns in primes have been known since Erasthosenes was back in BC times. So if you see a pattern here just remember that the pattern comes from looking at a period of a composite number and within that composite number there's guaranteed periodic gaps in primes where the factors of that number repeat.
This btw is something mathematicians deal with a lot. People seem to think prime numbers have no patterns and any view of them that reveals patterns is a surprising which is a weird misconception. Prime numbers absolutely have patterns. It's the basis for prime number theory.
Thanks! Do you mean you’d like to be able to input any number you like?
The numbered values are editable inputs. You can click into them and type in the amount you’d like. If you couldn’t tell they were editable inputs, that’s valuable feedback! I’ll redesign them to make it more obvious that you can do so, and don’t have to just click the +/- buttons.
I think they mean that the number that the image starts on is by default 0, I think they want to be able to change the starting number so top left could start at something else and increment from there. Adding on to that it would also be interesting to change what the number increments by.
Add option to skip all even numbers, another to skip all numbers ending with 5. Also, a way to see the number when you click a pixel or space.
It's fun seeing all these patterns. I did some edit. I was thinking that skipping over numbers divisible by 2 and 5 will get rid of most visible gaps, but they keep emerging.
The density of prime numbers remains remarkably consistent as you increase the grid size. Even the end of a 10,000 x 10,000 grid had just as many primes per inch as the earlier numbers
I made a screen recording of it: https://n0ssc.com/wp-content/uploads/2025/08/prime-doublespe...
Now when you take a vertical pattern like you see with column width=10 and add one more to the column size (so make it 11) the pattern is now offset by one pixel on each row. This makes the vertical pattern render diagonally as each row is offset by a pixel.
So you get the patterns going between vertical and diagonal. This can get really interesting when you have a bunch of composite numbers in a row. Each composite number has it's own vertical pattern as described above. So 435 has gaps every 3rd and 5th number (and for other factors) since those will be multiple of 3 or 5. Now the next number, 436 rotates this pattern 45degrees since it offsets each row by 1 pixel. But.. 436 has it's own patterns, eg. every second number is a multiple of 2 when offset from 436 since 436 is even. So it has it's own vertical patterns but also shows the diagonals from gaps in 435.
Anyway these well understood gaps in primality give a galaxy appearance for this simple reason. You're seeing well understood vertical patterns shifting to render diagonally with new vertical patterns from alignment on the next number and repeat.
https://lemire.me/blog/2017/09/18/visiting-all-values-in-an-...
For all integers n ≥ 0, the ranges [243 + (n * 546)] to [249 + (n * 546)] inclusive appear to contain no prime numbers. Same with the ranges [297 + (n * 546)] to [303 + (n * 546)].
For both sets of ranges, the minimum gap between the closest neighbouring primes appears to be at least 10 (in decimal). Does anyone know of a number-theoretic explanation for this kind of pattern?
In a similar way 210=2*3*7*5 also gives wide empty columns (if you ignore ignore first row where 2,3,5,7 themselves are primes)
It helps if you think of it in terms of where the non primes are located instead of where the primes are. Multiples of 2, 3, 5 form a very regular pattern. Wrap it around in a grid and you get straight lines which are either straight vertical or slightly shifted depending on the divisors of width. Stack a couple of repetitive patterns and you still get a repetitive pattern. If the positions which are not primes form a regular pattern, the inverted image also forms recognizable pattern. Of course the primes don't form perfectly regular pattern and but most the visible repetition are result of small prime multiples.
546n + 242 is always even
546n + 243 is always divisible by 3
546n + 244 is always even
546n + 255 is always divisible by 7.
Etc.
It's similar to how in base 10 you never see a prime ending in 0,2,4,6,8 or 5 since those numbers are clearly divisible by 2 or 5. In 546's case you have a lot of factors so even more gaps.
You also get the pattern appearing again since the number is even and the non-even factors repeat their pattern starting from the halfway point.
To finish it off (skipping even numbers)...
546n + 247 is always divisible by 13.
546n + 249 is always divisible by 3.
In this case you're seeing the extension of this to include multiples of 3. That is, all prime numbers above 6 are of the form 6n+1 or 6n+5, all other numbers are either divisible by 2 or 3.
You can extend these patterns. Whenever you have a composite number you'll get periodic points where factors are known. Eg. to extend it one step further you could say all prime numbers above 30 are of the form 30n + [1,7,11,13,17,19,23,29], all others are divisible by 2, 3 or 5.
From this you can also quickly iterate towards to the prime number formula for the frequency of primes. eg. Only half of numbers above 2 can be prime (1/2), the rest are multiples of 2. Over 6 you have half of two thirds of numbers that can possibly be prime, the rest are multiples of 2 or 3. Over 30 only 1/2 x 2/3 x 4/5 could possibly be prime. etc. This converges to the prime number theorem!
Anyway if anyone ever expresses amazement that's good to see but mathematically it's well known. Prime numbers have patterns in their frequency, specifically where there's period multiples of factors there can't possibly be primes. It's the basis for prime number theory and patterns in primes have been known since Erasthosenes was back in BC times. So if you see a pattern here just remember that the pattern comes from looking at a period of a composite number and within that composite number there's guaranteed periodic gaps in primes where the factors of that number repeat.
This btw is something mathematicians deal with a lot. People seem to think prime numbers have no patterns and any view of them that reveals patterns is a surprising which is a weird misconception. Prime numbers absolutely have patterns. It's the basis for prime number theory.
If n is prime and n > 3, then n ≡ 1 (mod 6) or n ≡ 5 (mod 6).
Or more succinctly:
n ≡ ±1 (mod 6).
So when the total number of columns is a multiple of 6, all the primes greater than 3 line up on the nth columns for n = 1, 5, 7, 11, etc.
Check out 431 columns - this yields no obvious persistent patterns.
The numbered values are editable inputs. You can click into them and type in the amount you’d like. If you couldn’t tell they were editable inputs, that’s valuable feedback! I’ll redesign them to make it more obvious that you can do so, and don’t have to just click the +/- buttons.
It's fun seeing all these patterns. I did some edit. I was thinking that skipping over numbers divisible by 2 and 5 will get rid of most visible gaps, but they keep emerging.