login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = PrimePi(n+2) - PrimePi(n).
3

%I #28 May 07 2021 17:52:34

%S 2,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,1,1,0,0,0,0,

%T 1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,

%U 1,1,1,1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,1,1,1,1

%N a(n) = PrimePi(n+2) - PrimePi(n).

%C For n>1, a(n) = 1 if n+1 or n+2 is prime, otherwise a(n) = 0. - _Robert Israel_, Mar 30 2017

%H G. C. Greubel, <a href="/A090405/b090405.txt">Table of n, a(n) for n = 1..1000</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/Hardy-LittlewoodConjectures.html">Hardy-Littlewood Conjectures</a>

%p with(numtheory): A090405:=n->pi(n+2)-pi(n): seq(A090405(n), n=1..150); # _Wesley Ivan Hurt_, Mar 30 2017

%t Table[Subtract @@ Map[PrimePi, n + {2, 0}], {n, 120}] (* or *)

%t Table[Boole@ PrimeQ[n + 1 + Boole[OddQ@ n]] + Boole[n == 1], {n, 120}] (* _Michael De Vlieger_, Mar 30 2017 *)

%o (PARI) for(n=1, 100, print1(primepi(n + 2) - primepi(n),", ")) \\ _Indranil Ghosh_, Mar 31 2017

%o (Python)

%o from sympy import primepi

%o print([primepi(n + 2) - primepi(n) for n in range(1, 101)])

%o # _Indranil Ghosh_, Mar 31 2017

%o (Python)

%o from sympy import isprime

%o def a(n):

%o if n<2: return 2

%o else:

%o if isprime(n + 1 + (n%2 == 1) + (n==1)): return 1

%o else: return 0 # _Indranil Ghosh_, Mar 31 2017

%Y Cf. A000720, A080545, A090406.

%K nonn,easy

%O 1,1

%A _Eric W. Weisstein_, Nov 29 2003