I wanted to see if the numbers preceding primes behaved differently in any way form the numbers succeeding primes so I calculated at the average number of divisors of number of the form $p-1$ and $p+1$ where $p$ is a prime.

Let $d(n)$ be the number of divisors of $n$. Define $f(x) = \sum_{p \le x} d(p-1)$ and $g(x) = \sum_{p \le x} d(p+1)$ where $p$ is a prime. I observed that there are only $3251$ instances where $f(x) < g(x)$. The largest value of $x$ for which this is true is $x = 3752789$. After checking till $x \le 1.9 \times 10^{10}$, I could not find the inequality reversing again.

This the data shows that the numbers preceding primes have on a average fewer number of divisors than the numbers succeeding primes. The graph below shows the actual data.

Question: Is there any reason why this should be true?

enter image description here

Source code

import numpy
p = 2
i = fd = fp = 0
d1 = d2 = p1 = p2 = 0
target = step = 10^6

while True:
    i  = i + 1  
    d1 = d1 + len(divisors(p-1))
    d2 = d2 + len(divisors(p+1))
    if d1 > d2:
        fd = fd + 1
    p1 = p1 + len(prime_factors(p-1))
    p2 = p2 + len(prime_factors(p+1))
    if p1 > p2:
        fp = fp + 1
    if i > target:
        print i,p,d1,d2,fd, d2-d1,(d2-d1)/i.n(), p1,p2,fp, p2-p1
        target = target + step
    p = next_prime(p)
  • 1
    $\begingroup$ Interesting. Is the difference significant? I mean...what does $|f(x)-g(x)|$ look like? Or $\frac {f(x)}{g(x)}$. $\endgroup$
    – lulu
    Jun 16, 2020 at 21:03
  • 1
    $\begingroup$ reminds me of this similar but different question $\endgroup$ Jun 16, 2020 at 21:04
  • 1
    $\begingroup$ One possible reason, but I haven't investigated how significant it can be, is that, at least for smaller primes, the primes modulo $3$ have more congruent to $2$ than $1$ (e.g., see the answer to MO's Consecutive Primes mod 3) and the primes modulo $4$ have more congruent to $3$ than $1$ (e.g., see the answer to MO's A "bit" of primes). This similar issue appears to also be the case for some other modulos, at least for smaller primes. $\endgroup$ Jun 16, 2020 at 21:07
  • 1
    $\begingroup$ Related to my comment above, I only skimmed through the paper, but it seems the first part of it which you can access from arXiv at Prime Number Races has some possible useful information for you. For example, near the bottom of page #$5$, it says the # of primes less than $x$ of the form $3n + 1$ out-number those of $3n + 2$ first only at $x = 608\text{,}981\text{,}813\text{,}029$. $\endgroup$ Jun 16, 2020 at 21:29
  • 1
    $\begingroup$ $\sum_{3k \le x} d(3k)=5/9(x\log x)+O(x)$ while the others (on $3k \pm 1$) are $(2/9)x\log x +O(x)$ each, so it is a $5/2$ ratio in the main term- I expect the fact that $3n+2$ wins the prime race so much oftener and $3n+3$ succeeds it, explains the data; proving it though may be quite hard $\endgroup$
    – Conrad
    Jun 17, 2020 at 0:20

1 Answer 1


Too long for a comment,

For $a=\pm 1$ $$\sum_p d(p -a)p^{-s}=\sum_{k\ge 1} \sum_{lk+a \ prime} (lk+a)^{-s}=\sum_{k\ge 1} \sum_{\chi\bmod k} \frac{\chi(a)}{\varphi(k)}\sum_p \chi(p)p^{-s}$$

$$\sum_p (d(p-1)-d(p+1))p^{-s}=\sum_k \sum_{\chi\bmod k} \frac{1-\chi(-1)}{\varphi(k)}\sum_p \chi(p)p^{-s}$$

Under the GRH each term is analytic for $\Re(s) > 1/2$,

If $\chi^2$ is a non-trivial character then $\sum_p \chi(p)p^{-s}$ is analytic at $s=1/2$, if $\chi$ is a quadratic character then as $s\to 1/2^+$ $$\sum_p \chi(p)p^{-s}=\sum_{m\ge 1}\frac{\mu(m)}{m}\log L(sm,\chi^m)\sim \frac{1}2\log(s-1/2)$$

thus $$\lim_{s\to 1/2^+}\frac{ \frac{1-\chi(-1)}{\varphi(k)}\sum_p \chi(p)p^{-s}}{\log(s-1/2)} =\frac{1_{\chi \text{ is a quadratic odd character}}}{\varphi(k)}$$ Is this not too bad to conjecture that ? $$\lim_{s\to 1/2^+}\sum_p (d(p-1)-d(p+1))p^{-s}=\color{red}{-\infty}$$ Estimating the growth of $\sum_{p\le x} d(p-1)-d(p+1)$ thus the abscissa of convergence of the Dirichlet series would help.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .