# Counting divisors of primes plus or minus 2

I was naively exploring the (usually) composites $\pm 2$ from a prime $p$, wondering if there might be some asymmetry, and made this histogram of the difference $\Delta$ in the number of divisors of $p \pm 2$:

Histogram of $\Delta(p)$ for the 1st $10^6$ primes $p$. The million$^{\mathrm{th}}$ prime is $15485863$.
More precisely, define $\Delta(n)$ to be $\tau(n+2)-\tau(n-2)$, where $\tau$ counts the number of divisors. The histogram shows the number of $\Delta(p)$ values just for $p$ a prime, for the first million primes.

For example:

• For $p=29$, $p+2=31$ is prime and so has $2$ divisors $\{1,31\}$ while $p-2=27$ has $4$ divisors $\{1,3,9,27\}$. So $\Delta(29) = -2$, and this contributes $1$ to the $\Delta=-2$ bar of the histogram.
• For $p=47$, $p+2=49$ has $3$ divisors $\{1,7,49\}$ while $p-2=45$ has $6$ divisors $\{1,3,5,9,15,45\}$. So $\Delta(47) = -3$, and this contributes $1$ to the $\Delta=-3$ bar of the histogram.
• For $p=523$, $p+2=525$ has $12$ divisors $\{1, 3, 5, 7, 15, 21, 25, 35, 75, 105, 175, 525\}$ while $p-2=521$ is prime and so has $2$ divisors $\{1,521\}$. So $\Delta(523) = 10$, and this contributes $1$ to the $\Delta=10$ bar of the histogram.

My question is:

Q. What explains the structural features of this histogram? In particular:

1. Why are odd $\Delta$ values so much smaller than even values? Note: They are (in general) non-zero. For example, among the first $10^6$ primes, $39$ have $\Delta=1$ and $31$ have $\Delta=-1$.
2. Why is the histogram so symmetric? For example, among the first $10^6$ primes, $100016$ have $\Delta=4$ and $100280$ have $\Delta=-4$.
3. Why do the $\Delta$'s divisible by $4$ ($0,\pm 4, \pm 8, \ldots$) appear to follow one normal distribution,
4. while the $\Delta$'s in between ($\pm 2, \pm 6, \pm 10, \ldots$)—equal $2 \bmod 4$—appear to follow a lower-amplitude normal distribution.

Other features are visible at larger $|\Delta|$ values, but perhaps these would wash out as $p \to \infty$.

• The only numbers with an odd number of divisors are perfect squares. That you see them at all relates to a problem of Landau: are there infinitely many primes which are one more than a square. In your case, two away from a square. Gerhard "Not Often Off By One" Paseman, 2018.08.25. – Gerhard Paseman Aug 26 '18 at 0:18
• Similarly, use multiplicativity of tau to classify numbers whose tau value is a multiple of four versus those that aren't (at most one prime has to have a power that is odd, and is not 3 mod 4.). I think finding how tau distributes mod 4 may enlighten. Gerhard "It's Elementary, My Dear Joseph" Paseman, 2018.08.25. – Gerhard Paseman Aug 26 '18 at 0:24