cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A196698 Number of primes of the form 3^n +- 3^k +- 1 with 0 <= k < n.

Original entry on oeis.org

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

Views

Author

Lei Zhou, Oct 05 2011

Keywords

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

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.
		

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