login
Characteristic function of non-isolated nonprimes.
1

%I #35 Feb 22 2022 00:08:05

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

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

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

%N Characteristic function of non-isolated nonprimes.

%C Non-isolated nonprimes in the sense that at least one of the two adjacent integers is also a nonprime.

%H Antti Karttunen, <a href="/A292438/b292438.txt">Table of n, a(n) for n = 0..65539</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%F a(0)=1, a(1)=1, a(2)=0, a(n) = 1 - A010051(n-((n+1) mod 2)) * A010051(n+((n+1) mod 2)) for n > 2.

%F a(n) = 1 - (pi(n) - pi(n-2))*(pi(n+1) - pi(n-1)), for n>3, where pi = A000720. - _Ridouane Oudra_, Jan 10 2022

%t a[0] = 1; a[1] = 1; a[2] = 0; a[n_] := 1 - (PrimePi[n - Mod[n + 1, 2]] - PrimePi[n - Mod[n + 1, 2] - 1]) (PrimePi[n + Mod[n + 1, 2]] - PrimePi[n + Mod[n + 1, 2] - 1]); Table[a[n], {n, 0, 100}]

%o (PARI) A292438(n) = if(n<2,1,!isprime(n)&&((!isprime(n-1))||(!isprime(n+1)))); \\ _Antti Karttunen_, Jul 02 2018

%Y Cf. A000720, A010051, A014574, A141468, A164276.

%K nonn

%O 0,1

%A _Wesley Ivan Hurt_, Mar 31 2018

%E More terms from _Antti Karttunen_, Jul 02 2018