Live data from Hacker News

Show HN: Prime Number Grid Visualizer

enda.sh

11–20 of 53 posts

Re: Show HN: Prime Number Grid Visualizer

#11
post #4

I'm probably an idiot but having the columns at a multiple of 6 is very pleasing

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.

Re: Show HN: Prime Number Grid Visualizer

#12
post #4

I'm probably an idiot but having the columns at a multiple of 6 is very pleasing

A prime number greater than 3 must leave a remainder 1 or 5 when divided by 6. In other words:

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.

Re: Show HN: Prime Number Grid Visualizer

#15
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.

Re: Show HN: Prime Number Grid Visualizer

#17
post #6

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. I made a screen recording of it: https://n0ssc.com/wp-content/uploads/2025/08/prime-doublespe...

I did the same thing and saw galaxies

I was waiting for

          .....   ......   ......   ....   ..    ..   ......
         ..       ..   ..  ..   ..   ..    ...   ..   ..     
         ..       ..   ..  ...  ..   ..    .. .. ..   ..     
          .....   ......   ......    ..    .. .. ..   ..  ...
           .....  ...      .. ..     ..    ..   ...   ..   ..
              ..  ..       ..  ..    ..    ..    ..   ...  ..
         ......   ..       ..   ..  ....   ..    ..    .....

to show up, until I realized I've been coding too much today.

Re: Show HN: Prime Number Grid Visualizer

#19
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?

Re: Show HN: Prime Number Grid Visualizer

#20
post #19

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 ex…

I am interested to know how you discovered this! Was it by happenstance or did you know to look for this?
Post reply on HN