| ▲ | susam 3 days ago |
| Hello! I wrote this simple prime number grid visualiser last night, just for fun. It is inspired by the "Show HN" post https://news.ycombinator.com/item?id=44888548 that I stumbled upon a few days ago. My tool uses the Miller-Rabin primality test with prime bases drawn from https://oeis.org/A014233 to determine whether a number is prime. This allows it to handle numbers up to 3317044064679887385961980. For example, https://susam.net/primegrid.html#3317044064679887385961781-2... shows the upper limit of the numbers this tool can check. The three circles displayed there represent the following prime numbers: 3317044064679887385961783
3317044064679887385961801
3317044064679887385961813
I hope this is fun for you too! |
|
| ▲ | Tepix 3 days ago | parent | next [-] |
| Great visualization! Can you please add a on-mouse-over so when i hover my mouse over a dot i can see the prime number it represents? Would we see new patterns emerge if the number of columns increases per row by X (X being constant or perhaps prime numbers ;-) )? |
| |
| ▲ | susam 3 days ago | parent [-] | | Adding mouseover text to every prime number slows down rendering on large grids (say, with a million or more numbers). So mouseover text is available as an optional feature. You can toggle it using the 't' button at the top: click once to enable the text, and click again to disable it. | | |
| ▲ | Tepix 3 days ago | parent [-] | | Thanks, that was fast! Here's an idea on how to implement it without the slowdown:
https://jsfiddle.net/qpswztj8/ Given that it's a preformatted text with a known number of columns, the number below the mouse pointer can be computed using the mouse position, character width and line height. |
|
|
|
| ▲ | camillomiller 3 days ago | parent | prev | next [-] |
| It's so cool actually! You actually sent me on a rabbit hole trying to visually look for patterns :D
But I guess the discretionality with which you can organize in rows and columns makes mine quite a pointless excercise :D |
| |
| ▲ | jona-f 3 days ago | parent [-] | | If you select 30, 60 or 90 columns you get the clearest patterns. It kinda seems that the more divisors the number of columns has, the clearer the vertical clusters are. And somehow 30, 60 and 90 stand out. Number theory is so weird. I expected more randomness. | | |
| ▲ | susam 3 days ago | parent | next [-] | | The reason vertical clusters appear in these examples is that all your chosen numbers are multiples of 6. A prime number greater than 3 leaves a remainder of either 1 or 5 when divided by 6. In other words: For all primes p greater than 3, p ≡ ±1 (mod 6). Therefore, when the total number of columns is a multiple of 6, all primes except 2 fall into the same columns, namely 1, 5, 7, 11, 13, 17 and so on. | | | |
| ▲ | dgacmu 3 days ago | parent | prev | next [-] | | If you can do 210 you'll see even more. Any primorial will give you the strongest patterns. (Primorials are the products of the first N primes, so 2, 6, 30, 210, etc.) | |
| ▲ | Daub 3 days ago | parent | prev | next [-] | | Very cool. Go from 30 to 31 to see this ‘pattern’ twist in on itself. | |
| ▲ | ainiriand 3 days ago | parent | prev [-] | | Go for 258 and be ready to get your mind blown. | | |
|
|
|
| ▲ | shredprez 3 days ago | parent | prev | next [-] |
| Thank you for making and sharing this! It's fun to quickly increment the column counter and spot repeating patterns over time — little spiral movements, big swinging lines. Growing up I loved math's logic puzzle elements, but it got tough when presentation of the subject became more abstract in late high school and college. Visualization tools like this would have gone a long way toward making the concepts concrete and keeping me curious about the relationships behind the symbols. |
|
| ▲ | davedx 3 days ago | parent | prev [-] |
| I think another interesting feature would be if you could change the number base to 16 or some other base, I'm really curious if the pattern would change. |
| |
| ▲ | susam 2 days ago | parent | next [-] | | > I think another interesting feature would be if you could change the number base to 16 or some other base, I'm really curious if the pattern would change. Whether a number is prime has nothing to do with the base we use to write it. Changing the base wouldn't affect the visualisation at all. A number is either prime or not regardless of base. Since this grid only marks prime positions with circles, the pattern would look exactly the same. In fact, you can already imagine the numbers in any base you like while looking at the visualisation. | | | |
| ▲ | lblume 3 days ago | parent | prev | next [-] | | Numbers are prime irrespective of base. | | |
| ▲ | ForOldHack 3 days ago | parent | next [-] | | Since I seriously doubt that these numbers were checked in decimal, I would be led to believe base-2 is working and working well, as well as all other even bases. Ood bases would be fun,but much slower. I tried odd number of rows and prime number of rows. All very interesting. | |
| ▲ | xandrius 3 days ago | parent | prev [-] | | So it's already supported! |
| |
| ▲ | teytra 3 days ago | parent | prev [-] | | Set columns to 6, and the pattern is changed in an "interesting" way. All primes are n*6 +/- 1 (after the primes 2 and 3 that are "special"). | | |
| ▲ | jalk 3 days ago | parent [-] | | Set cols to anything divisible by 6, to get the same kind of "stacks" with more cols (i.e. 90) |
|
|