login
a(n) = 1 if 2*n + 1 is prime, otherwise a(n) = 0.
21

%I #47 Sep 08 2022 08:45:16

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

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

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

%N a(n) = 1 if 2*n + 1 is prime, otherwise a(n) = 0.

%C Inverse Mobius transform of the sequence, after dropping a(0), yields A086668. - _R. J. Mathar_, Jan 25 2009

%C If we drop a(0) then we may describe the sequence as: for all numbers k(n) [k(n) = 4 ceiling(n/2) + (-1)^n] congruent to -1 or +1 (mod 4) starting with k(n) = {3,5,7,9,11,...}, a(k(n)) is 1 if k(n) is prime and 0 if k(n) is composite. - _Daniel Forgues_, Mar 01 2009

%D D. H. Lehmer, "Computer Technology Applied to the Theory of Numbers," from Studies in Number Theory, ed. William J. LeVeque. Englewood Cliffs, New Jersey: Prentice Hall (1969): 138.

%H Daniel Forgues, <a href="/A101264/b101264.txt">Table of n, a(n) for n=0..49999</a>

%F a(n) = A057427(A085090(n+1)). - _Reinhard Zumkeller_, Sep 14 2006

%F For n > 0, a(n) = (2n-1)! mod (2n+1). - _Thomas Ordowski_, Jul 23 2016

%F a(n) = pi(2*n+1) - pi(2*n), where pi(n) = A000720(n). - _Ridouane Oudra_, Aug 25 2019

%e a(1) = 1 because 2*1+1 = 3 is prime;

%e a(2) = 1 because 2*2+1 = 5 is prime;

%e a(3) = 1 because 2*3+1 = 7 is prime;

%e a(4) = 0 because 2*4+1 = 9 is composite.

%p with(numtheory): a:= proc(n) if isprime(2*n+1)=true then 1 else 0 fi end:

%p seq(a(n), n=0..80); # _Ridouane Oudra_, Aug 25 2019

%t Table[If[PrimeQ[2n + 1], 1, 0], {n, 0, 104}] (* _Ray Chandler_, Jan 09 2005 *)

%t Table[Boole[PrimeQ[n]], {n, 1, 209, 2}] (* _Alonso del Arte_, Sep 25 2012 *)

%o (Magma) [IsPrime(2*n+1) select 1 else 0: n in [1..100]]; // _Marius A. Burtea_, Aug 25 2019

%o (PARI) first(n) = {my(res = vector(n)); forprime(p = 3, 2*n - 1, res[p \ 2] = 1); res} \\ _David A. Corneth_, Aug 25 2019

%Y Bisection (odd n) of A010051.

%Y Cf. A065091, A063524, A000720.

%Y If we drop a(0), equals absolute value of A156707. - _Daniel Forgues_, Mar 01 2009

%K easy,nonn

%O 0,1

%A _Giovanni Teofilatto_, Dec 18 2004

%E Corrected by _Ray Chandler_, Jan 09 2005