OFFSET
1,1
COMMENTS
Conjecture: all elements of this sequence are greater than 0.
Conjecture verified up to n = 7399.
I conjecture the contrary: infinitely many elements of this sequence are equal to 0. Probably the first n with a(n) = 0 is less than a million. - Charles R Greathouse IV, Nov 21 2011
This is also number of primes in n-digit balanced ternary form with no more than three nonzero digits for n > 1. - Lei Zhou, Dec 04 2013
LINKS
Lei Zhou, Table of n, a(n) for n = 1..6205
Lei Zhou, A 400,000 decimal digits balanced ternary prime with three non-zero digits, found on Jan 02 2015.
EXAMPLE
n = 1, 3 = 3^1 + 3^0 - 1 = 3^1 - 3^0 + 1; 5 = 3^1 + 3^0 + 1, two primes found, so a(1) = 2;
n = 2, 5 = 3^2 - 3^1 - 1; 7 = 3^2 - 3^1 + 1 = 3^2 - 3^0 - 1; 11 = 3^2 + 3^1 - 1 = 3^2 + 3^0 + 1; 13 = 3^2 + 3^1 + 1, four primes found, so a(2) = 4;
...
n = 7, 1459 = 3^7 - 3^6 + 1; 2161 = 3^7 - 3^3 + 1; 2179 = 3^7 - 3^1 + 1; 2213 = 3^7 + 3^3 - 1; 2267 = 3^7 + 3^4 - 1; 2269 = 3^7 + 3^4 + 1; 2917 = 3^7 + 3^6 + 1, seven primes found, so a(7) = 7.
MATHEMATICA
Table[c1 = 3^i; cs = {};
Do[c2 = 3^j; cp = c1 + c2 + 1; If[PrimeQ[cp], cs = Union[cs, {cp}]];
cp = c1 + c2 - 1; If[PrimeQ[cp], cs = Union[cs, {cp}]];
cp = c1 - c2 + 1; If[PrimeQ[cp], cs = Union[cs, {cp}]];
cp = c1 - c2 - 1;
If[PrimeQ[cp], cs = Union[cs, {cp}]], {j, 1, i - 1}];
Length[cs], {i, 2, 100}]
(* Alternative: *)
Table[s = 3^i; ct = 0; Do[t = 3^j; a1 = s + t; a2 = s - t; If[PrimeQ[a1 + 1], ct++]; If[PrimeQ[a1 - 1], ct++]; If[PrimeQ[a2 + 1], ct++]; If[PrimeQ[a2 - 1], ct++], {j, 1, i - 1}]; ct, {i, 2, 100}] (* Lei Zhou, Mar 19 2015 *)
PROG
(PARI) a(n)=sum(k=0, n-1, isprime(3^n-3^k-1)+isprime(3^n-3^k+1)+isprime(3^n+3^k-1)+isprime(3^n+3^k+1)) \\ Charles R Greathouse IV, Oct 06 2011
CROSSREFS
KEYWORD
nonn
AUTHOR
Lei Zhou, Oct 05 2011
STATUS
approved