OFFSET
1,10
COMMENTS
EXAMPLE
A274987 = {3, 5, 7, 11, 13, 17, 23, 31, 37, 53, 59, 61, 73, 79, 83, 89, 101, 103, 109...}
For n=6, c=1, 6=3+3, 3=10 in balanced ternary(BT). 3 is a 2 trits BT number. 2-2=0<1, so this one counts, a(6)=1;
...
For n=20, c=1, 20=3+17=7+13. For 3 and 17 pair, 3=10(BT), 17=1T0T(BT), the difference of trits of these two primes is 2. This does not count. For 7 and 13 pair, 7=1T1(BT), 13=111(BT), the difference of trits of these two primes is 0. This is counted. So a(20)=1;
...
For n=29, c=2, 29=23+2*3=7+2*11=3+2*13. For 23 and 3 pair, 23=10TT(BT), 3=10(BT), the difference of trits of these two primes is 2, this does not count; for 7 and 11 pair, 7=1T1(BT), 11=11T(BT), the difference of trits of these two primes is , this is counted; for 3 and 13 pair, 3=10(BT), 13=111(BT), the difference of trits of these two primes is 1, this is counted. So a(29)=2.
MATHEMATICA
p = 3; sp = {p}; Table[l = Length[sp]; While[sp[[l]] < n, While[p = NextPrime[p]; cp = 2*3^(Floor[Log[3, 2*p - 1]]) - p; ! PrimeQ[cp]]; AppendTo[sp, p]; l++]; c = 2 - Mod[n + 1, 2]; ct = 0; Do[If[MemberQ[sp, n - c*sp[[i]]], If[Abs[Floor[Log[3, 2*sp[[i]] - 1]] - Floor[Log[3, 2*(n - c*sp[[i]]) - 1]]] <= 1, If[c == 1, If[(2*sp[[i]]) <= n, ct++], ct++]]], {i, 1, l}];
ct, {n, 1, 87}]
CROSSREFS
KEYWORD
AUTHOR
Lei Zhou, Nov 18 2016
STATUS
approved