Munim Technologies

Research/Mathematics

The digit parity of prime gaps has memory, but so do other sieves

The parity of the binary digit sum of consecutive prime gaps is strongly correlated, but our pre-registered controls show the same memory, even stronger, in the gaps between squarefree numbers. This is numerical evidence up to 10^8, not a proof.

Oct 18, 2026 · 6 min read

Write each gap between consecutive primes in binary and ask whether it has an odd or even number of ones. The resulting sequence of odd and even values is far from random: neighbouring gaps disagree much more often than chance allows, with a z-score of −120.6 over the primes up to 10^8. We expected this memory to be special to primes and wrote that prediction down before testing it. It was wrong. The gaps between squarefree numbers, a much simpler sequence, show the same kind of memory, and in base 2 it is more than four times stronger (z = −502.4). This matters because it means the prime signal, by itself, is not evidence of anything deep about the primes.

−120.6

lag-1 z for prime gaps up to 10^8, base 2

−502.4

lag-1 z for squarefree gaps up to 10^8, base 2

≈ 8

coefficient of the density law, held at 29, 31 and 37

The question

Digit sums of primes have a long history: Mauduit and Rivat proved in 2010 that, in the limit, primes with odd and even digit sums are equally common. Our companion study, prime-digit-parity, looked instead at the gaps between primes. For each gap g we take χ(g) = +1 if its base-b digit sum is even and −1 if it is odd, and measure how often neighbouring values agree. We compare that count with an exact permutation null: the same multiset of +1s and −1s, shuffled. Because the null keeps the overall mix of odd and even fixed, any deviation is serial structure, not bias in the marginal counts.

For the 5,761,454 prime gaps below 10^8 the lag-1 z-score is −120.6 in base 2, −33.3 in base 8 and −58.1 in base 16. The question for this work was whether that memory belongs to the primes or to any sequence produced by a sieve.

What we did

We ran the same statistic on the gaps of other sieved sequences, each with predictions fixed in writing before any data existed. Squarefree numbers (no repeated prime factor) have positive density and gaps of at most 10 below 10^8. Sums of two squares thin out slowly and have gaps that keep growing. Lucky numbers come from a positional sieve with no multiplicative input at all. Every run used the standard library or numpy, passed built-in self-tests against brute force before reporting any statistic, and ships its raw output.

What we found

Lag-1 z-scores of gap digit-sum parity, cutoff 10^8

SequenceBase 2Base 4Base 8Base 16
Primes−120.6+18.1−33.3−58.1
Squarefree numbers−502.4−118.6−144.2−144.2
Sums of two squares+23.4−278.6−104.4−260.9
Negative z means neighbouring gaps disagree more often than in a random shuffle. Sources: squarefree-gap-parity data/results.json and data/sumsq_results.json; prime-digit-parity data/gap_parity_lagk.csv.

Our pre-registered prediction for squarefree numbers was a quiet control, with |z| below about 5. Every squarefree lag-1 z-score fell between 119 and 502. Sums of two squares are loud too, but with a different shape: base 2 is the quietest base (+23.4) and base 4 the loudest (−278.6). The lucky numbers, run to 10^7 with a runs test, are also anti-persistent in base 2 (z = −16.99), but our prediction that base 2 would dominate failed: base 16 was strongest (−27.51). Raw z grows with the number of gaps, so it is not an effect size; scaled by the square root of the sample size, the three loud effects up to 10^8 are of the same order, about 0.05 to 0.065.

A signature that does point somewhere. The companion repository then looked for a feature that separates sieves. Over n ≤ 2×10^7, squarefree gaps in base 2 are loud at every lag from 1 to 8 except lag 2, where |z| is 2.9 against a median of 196 at the other lags, a ratio of 0.0149. Primes do not show this (ratio 6.44), and neither do the lucky numbers, cubefree numbers or odd squarefree numbers. To see how strict the squarefree condition must be, we let one prime p appear squared and measured the lag-2 ratio r(p). Below 11 the quiet lag disappears. From 11 upward it returns, and r(p) falls steadily toward the control.

Lag-2 quiet ratio when one prime may appear squared

00.250.50.7515101520253035Relaxed prime pLag-2 |z| ÷ median |z| at other lags
The signature counts as present when the ratio is at most 0.1. Strict squarefree numbers give 0.0149. We had predicted the signature would stay absent at 11 and 13; that prediction failed. Base 2, n ≤ 2×10^7. Source: prime-digit-parity data/axis_d5_density_scaling_law.json (grading.ratio_by_relaxed_prime)

The excess over the control tracks how many extra numbers the relaxation lets in, a density of 1/p² − 1/p³. The coefficient k = (r(p) − r_control) ÷ (1/p² − 1/p³) was estimated from primes up to 23, locked to the band 5 to 11, and then held on new data at 29, 31 and 37. Relaxing two or three primes at once gave the same coefficient when the densities were added, including the triple 41, 43, 47, which had never been measured before.

Density-law coefficient k on held-out relaxations

Primes relaxedRatio rCoefficient k
290.02397.86
310.02287.84
370.02088.42
17, 190.06398.33
23, 290.03827.91
31, 370.02878.06
17, 19, 230.07868.29
29, 31, 370.03787.99
41, 43, 470.02788.31
Pre-registered band: 5 to 11. Sources: prime-digit-parity data/axis_d5_density_scaling_law.json, data/axis_d6_density_additivity.json, data/axis_d7_three_prime_additivity.json.

What it means

Serial memory in gap digit parity is not a fingerprint of the primes. Any rigidly structured gap sequence departs strongly from a shuffled one, and this statistic cannot tell a prime mechanism apart from an ordinary sieve. The lag-2 quiet is more specific: it appears only in the strict squarefree sieve among those we tested, and its decay when the sieve is loosened follows a simple additive law. We do not have an explanation for why the coefficient is close to 8. A later in-sample audit also found that k is not monotone in p: every prime up to 7 has k above 8.8, and the value rises again from 31 to 37, so the law is a good description above the crossover rather than a universal constant.

More research