Login
You're viewing the code4lib.social public feed.
  • Oct 17, 2026, 10:00 PM

    For no real reason, I decided to look at the frequency of gaps between the prime numbers: 1 between 2 and 3, 2 between 3 and 5, 2 again between 5 and 7, and so on. The results are noisier than I expected. Pretty consistently up to hundreds of millions, the most frequent gap by a large margin is 6, first appearing between 23 and 29.

    The ivy code:

    op gaps n =
    p = primes n
    gaps = (1 drop p) - -1 drop p
    u = u[up u = unique gaps]
    transp (2, (rho u)) rho u, (+/%@ u @== gaps)

    💬 1🔄 3⭐ 16

Replies

  • Oct 17, 2026, 10:01 PM

    gaps 1e6
    1 1
    2 8169
    4 8143
    6 13549
    8 5569
    10 7079
    12 8005
    14 4233
    16 2881
    18 4909
    20 2401
    22 2172
    24 2682
    26 1175
    28 1234
    30 1914
    32 550
    34 557
    36 767
    38 330
    40 424
    42 476
    44 202
    46 155
    48 196
    50 106
    52 77
    54 140
    56 53
    58 54
    60 96
    62 16
    64 24
    66 48
    68 13
    70 22
    72 13
    74 12
    76 6
    78 13
    80 3
    82 5
    84 6
    86 4
    88 1
    ...
    plus a few more.

    💬 0🔄 1⭐ 4
  • Oct 17, 2026, 10:02 PM

    Curious how much is known about this pattern, whether 6 is known to be dominant forever, and if the spikiness persists.

    Experimental number theory only gets me so far.

    💬 0🔄 1⭐ 3
  • Oct 18, 2026, 6:53 AM

    I made a graph (using primitive tools) that shows the shape of the histogram up to gaps of 100 for primes up to 10 million.

    It definitely has features. It certainly has a decay, which would be expected intuitively, but it also appears almost periodic, which would not.

    A spiky graph showing the shape of the histogram of gaps between the primes.
    💬 0🔄 1⭐ 4