Let:
$$x=2$$
$$t(1,1)=1$$ $$t(2,1)=0$$ $$t(3,1)=0$$
$$\text{ If }n=k \text{ then } t(n,k)= 1$$
$$\text{ if } n>3 \text{ else if } k=1 \text{ then }$$ $$t(n,k)= \text{sgn}((2- \prod _{i=1}^{n-1} t(n,i+k)- \prod _{i=1}^{n-1-x} t(n-x,i+k)) \cdot (2- \prod _{i=1}^{n-1} t(n,i+k)- \prod _{i=1}^{n-1+x} t(n+x,i+k)))$$
$$\text{ else if } n \bmod k=0 \text{ then } t(n,k) = t\left(\frac{n}{k},1\right) \text{ else } 1 \text{ else } 1$$
where $$\text{sgn}(x)$$ is the sign function.
This produces a characteristic sequence of non-twin primes for $n>2$ starting:
1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
which for $n>2$ is equal to $1$ if it is not a twin prime and equal to $0$ if it is a twin prime.
The positions of $0$ are at twin primes and the primes $2$ and $3$:
2, 3, 5, 7, 11, 13, 17, 19, 29, 31, 41, 43, 59, 61, 71, 73, 101, 103,
where the only non-twin prime is $2$.
I might have gotten the latex not entirely correct but the program below does what it is supposed to.
(*Mathematica start*)
Clear[t, n, k, i, nn];
nn = 1000;
t[1, 1] = 1;
t[2, 1] = 0;
t[3, 1] = 0;
t[n_, k_] :=
t[n, k] =
If[n == k, 1,
If[n > 3,
If[k == 1,
Sign[(2 - Product[t[n, k + i], {i, 1, n - 1}]/1 -
Product[t[n - 2, k + i], {i, 1, n - 1 - 2}]/1)*(2 -
Product[t[n, k + i], {i, 1, n - 1}]/1 -
Product[t[n + 2, k + i], {i, 1, n - 1 + 2}]/1)],
If[Mod[n, k] == 0, t[n/k, 1], 1], 1]]];
Monitor[a = Table[t[n, 1], {n, 1, nn}];, n];
Flatten[Position[a, 0]]
Flatten[Position[a, 1]]
(*Mathematica end*)
So my question is:
Is it considered cheating to use the sign function when sieving for twin primes?
With "cheating" I mean that nothing useful can come out of the sign function because $$\frac{0}{0}=\text{indeterminate}$$
The sequence without the sign function looks like this:
1, 0, 0, 2, 0, 4, 0, 4, 1, 4, 0, 4, 0, 4, 1, 4, 0, 4, 0, 4, 1, 4, 1, 4, 2, 4, 2, 4, 0, 4, 0, 4, 2, 4, 2, 4, 1, 4, 1, 4, 0, 4, 0, 4, 1, 4, 1, 4, 2, 4, 2, 4, 1, 4, 2, 4, 2, 4, 0, 4, 0, 4, 2, 4, 2, 4, 1, 4, 1,
There is a way to avoid using the sign function:
$t(n) =\;$1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0,
which is zero when $n=2$ or $n=$ a twin prime, and one otherwise.
The notation for the recurrence should be:
$t(1)=1$
$t(2)=0$
$n>2:$ $$t(n) = \left(1-\left({\prod_{d|n}}_\limits{d<n} t(d)\right)\left({\prod_{d|(n-2)}}_\limits{d<n} t(d)\right)\right)\left(1-\left({\prod_{d|n}}_\limits{d<n} t(d)\right)\left({\prod_{d|(n+2)}}_\limits{d<n} t(d)\right)\right)$$
if I am correct.