A101264 a(n) = 1 if 2*n + 1 is prime, otherwise a(n) = 0.
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, 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, 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
Offset: 0
Examples
a(1) = 1 because 2*1+1 = 3 is prime; a(2) = 1 because 2*2+1 = 5 is prime; a(3) = 1 because 2*3+1 = 7 is prime; a(4) = 0 because 2*4+1 = 9 is composite.
References
- 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.
Links
- Daniel Forgues, Table of n, a(n) for n=0..49999
Crossrefs
Programs
-
Magma
[IsPrime(2*n+1) select 1 else 0: n in [1..100]]; // Marius A. Burtea, Aug 25 2019
-
Maple
with(numtheory): a:= proc(n) if isprime(2*n+1)=true then 1 else 0 fi end: seq(a(n), n=0..80); # Ridouane Oudra, Aug 25 2019
-
Mathematica
Table[If[PrimeQ[2n + 1], 1, 0], {n, 0, 104}] (* Ray Chandler, Jan 09 2005 *) Table[Boole[PrimeQ[n]], {n, 1, 209, 2}] (* Alonso del Arte, Sep 25 2012 *)
-
PARI
first(n) = {my(res = vector(n)); forprime(p = 3, 2*n - 1, res[p \ 2] = 1); res} \\ David A. Corneth, Aug 25 2019
Formula
For n > 0, a(n) = (2n-1)! mod (2n+1). - Thomas Ordowski, Jul 23 2016
a(n) = pi(2*n+1) - pi(2*n), where pi(n) = A000720(n). - Ridouane Oudra, Aug 25 2019
Extensions
Corrected by Ray Chandler, Jan 09 2005
Comments