Wolfram Language code to test whether does $p$ provide the twin prime number pair via your conjecture or not is as follows.
twinPrimesQ[tp_]:=tp[[1]]+2==tp[[2]]&&PrimeQ[tp[[1]]]&&PrimeQ[tp[[2]]];
primesList[p_]:=Module[{out={Prime[3]},i},
For[i=4,Prime[i]<=p,i=i+1,
out=Append[out,Prime[i]];
];
out
];
testPrime[p_,pl_]:=Module[{out,found=False,twinPrimes,primeFactors,primeFactorsPowers,i},
twinPrimes={
{3 5 prod p-4,3 5 prod p-2},
{3 5 prod p+2,3 5 prod p+4}
};
primeFactors=primesList[p];
primeFactorsPowers=Tuples[Range[0,pl],primeFactors//Length];
For[i=1,i<=Length[primeFactorsPowers],i=i+1,
out=twinPrimes/.prod->Product[primeFactors[[k]]^primeFactorsPowers[[i]][[k]],{k,1,primeFactors//Length}];
found=twinPrimesQ[out[[1]]]||twinPrimesQ[out[[2]]];
If[found,Break[]];
];
If[found,out~Select~(twinPrimesQ[#]&)//First,False]
];
This defines a function twinPrime[p,pl]
where p
=$\,p$ and pl
is the maximum power of prime factors of $P_p$ to search upon. The function returns the first found twin pair or False
if it has failed.
For example:
You can try this online with Mathics.
To confirm or disprove your conjecture for ranges of primes, you can use
out=List[]; For[i=4,i<=7,i=i+1,out=out~Append~{i,Prime[i],testPrime[Prime[i],1]}]; out//TableForm
adjusting the bounds of search (values of j
in terms of consecutive number of primes) and maximum power of prime factors. This will output a table with three columns: the id of the prime being tested, the prime itself and the first twin prime pair found (or False
if none).
Let $n = 8$. Then all primes less than $8$ are $7, 5, 3, 2$. The product of these is $x = 210$.
$x + 1 = 211$ which is prime,
$x - 1 = 209 = 11\times19.$
Best Answer
As illustrated by one unified function which zeros show the distribution of relative prime, twin prime, prime pair of distance 2n (twin prime is special case of n=1, and prime is special case of n=0), and Goldbach sums of 2n, there indeed has relationship between these problems. Here's a summary and you can see more details from my research notes: https://fredyangblog.files.wordpress.com/2016/04/fourierseriesofprimes-rev1-3.pdf
I also created a live chart to demonstrate this: https://www.desmos.com/calculator/4a9i0ejeyk
Let $p_i$ be the $i^{th}$ prime, define $$ P(p_i,n,x)=\sum_{p\le{p_i}}\frac{c_p}{p}\left(1+2\sum_{k=1}^{p-1}(1-\frac{k}{p})\cos\frac{2kn\pi}{p}\cos\frac{2k\pi}{p}x\right), c_p = \begin{cases} 1, \text{ when $p \mid 2n$} \\ 2, \text{ when $p \nmid 2n$} \end{cases} $$ which zeros show $$ \begin{cases} \text{When $n=0$: prime distribution} \\ \text{When $n=1$: twin prime distribution as $(x-1,x+1)$} \\ \text{When $n>1$ and $0\le{x}<n$: distribution of Goldbach sums as $(n-x, n+x)$} \\ \text{When $n\ge{1}$ and $x>n$: distribution of prime pairs of distance of $2n$ as $(x-n, x+n)$} \end{cases} $$
Additionally, when $n=0$, for each integer $x$, it could show the number of prime divisors of $x$ that $\le p_i$.
The unified formula to calculate number of zeros $L$ on $[0,p_i\#)$ is, for all $3\le{p}\le{p_i}$, \begin{equation} L=\prod_{p|n}(p-1)\prod_{p \nmid n}(p-2) \end{equation}
For prime series, $n=0$ so $L=\prod(p-1)$; For twin prime series, $n=1$ so $L=\prod(p-2)$.