Why are multiples of 30 adjacent to prime numbers more often than any other number

prime numbers

This is closely related to this question, in which I asked about pairing of numbers in the same problem, which I defined as follows:

Given a number $n$, the sequence of "prime-adjacent multiples" is defined as any multiple $k$ that is $\pm 1$ away from a prime number.

It essentially boils down to: How frequently do multiples of my number live next to a prime number?

This can be calculated by running an extremely simple python script (as follows, just if you wanted to try this yourself):

import sympy
import numpy as np

c = []
for i in range(1000):
    c.append(0)
    for j in range(5000):
        if sympy.isprime(i*j - 1) or sympy.isprime(i*j + 1):
            c[-1] += 1
ind = np.argmax(c)
print(ind, c[ind])

Which will calculate the number of times a multiple of a number $n$ is adjacent to a prime for each $n$ from 0 to 1000, for the first 5000 multiples.

Running this shows that 30 has the most "prime-adjacent multiples" for the first 5000 multiples. As there was a bit of preamble, I'll restate: I want to know why this is. Why are multiples of 30 adjacent to prime numbers more often than any other number?

Not entirely related:

This may beg the question of how do I know 30 has prime-adjacent multiples "more often than any other number"? It's mainly down to observation, by plotting the count of prime-adjacent multiples for all numbers between 0 and 20,000 (this time for the first 1000 multiples, to save on computation time) gives the following graph:

enter image description here

Where the initial peak at the start is 30 (closely followed by 6). The graph would indicate that no number would ever be able to reach a peak similar in size to the numbers at the start.

Best Answer

There are two things. Factors of 30, and smallness of 30.
Neighbours of 30 are odd. Since almost all primes are odd and half of numbers are odd, that makes neighbours of 30 twice as likely to be prime. Also, not being multiples of 3 raises the odds by 3/2, and not being multiples of 5 gives another factor of 5/4. That is 15/4 times higher, compared with random numbers. Neighbours of 29 only get a boost of 29/28.
The other is the size of 30. Primes get rarer when you get higher; random numbers near N have a chance of about $1/\ln N$ to be prime. The middle of 1000 multiples of 30 is 15000, and $\ln15000=9.6$, but the middle of 1000 multiples of 210 is 105000, whose log is $11.56$. So, although 210 also excludes factors of 7 which gave an extra factor of 7/6 in the first paragraph, the log here washes it out. If you do 10000 multiples, neighbours of 210 might start to win out over multiples of 30.

Related Question