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”).

A129950
Indicator function of twin primes: 1 if n is a twin prime member, 0 if not prime, -1 else (isolated prime or 2).
4
0, -1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0
OFFSET
1,1
COMMENTS
Absolute values are the same as A010051.
FORMULA
a(n) = 2*A164292(n) - A010051(n). - Antti Karttunen, Jan 03 2019
MATHEMATICA
Array[If[PrimeQ@ #, If[Or[PrimeQ[# - 2], PrimeQ[# + 2]], 1, -1], 0] &, 100] (* Michael De Vlieger, Jan 03 2019 *)
PROG
(PARI) istwin(n) = local(p1, p2); if(n==5, return(2)); if(isprime(n), p1=n-2; p2=n+2; if(isprime(p1), return(1)); if(isprime(p2), return(-1)); return(0))
t(x) = if(abs(istwin(x))==1||x==5, 1, if(isprime(x), -1, 0))
for(j=1, 100, print1(t(j)", "))
(PARI) a(n) = if(isprime(n), (-1)^(!isprime(n-2) && !isprime(n+2)), 0); \\ Typos corrected by Antti Karttunen, Jan 03 2019
CROSSREFS
KEYWORD
sign
AUTHOR
Cino Hilliard, Jun 10 2007
EXTENSIONS
Definition and a(67) corrected by M. F. Hasler, Jan 20 2012
STATUS
approved