A196698 Number of primes of the form 3^n +- 3^k +- 1 with 0 <= k < n.
2, 4, 6, 8, 7, 11, 7, 10, 11, 11, 8, 10, 9, 11, 14, 11, 10, 14, 7, 16, 12, 12, 7, 17, 10, 7, 15, 13, 4, 11, 11, 11, 13, 6, 12, 18, 9, 12, 17, 14, 13, 11, 10, 11, 13, 6, 7, 17, 9, 14, 9, 10, 13, 20, 8, 11, 10, 9, 8, 16, 12, 12, 13, 8, 12, 14, 8, 8, 10, 13, 9
Offset: 1
Keywords
Examples
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.
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.
Crossrefs
Cf. A196697.
Programs
-
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 *)
-
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
Comments