login
Number of twin primes between non-twin prime(n) and non-twin prime(n+1).
1

%I #12 Jul 13 2021 19:56:02

%S 7,2,2,0,2,2,0,0,0,4,0,0,4,0,0,0,6,0,2,2,0,0,2,2,0,2,0,0,2,0,0,0,0,0,

%T 0,0,0,0,4,0,0,0,2,0,0,0,0,0,0,2,0,0,0,2,0,0,2,0,2,2,0,2,0,0,0,0,0,0,

%U 0,0,0,0,0,0,0,0,0,0,0,6,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,2,0

%N Number of twin primes between non-twin prime(n) and non-twin prime(n+1).

%H Harvey P. Dale, <a href="/A176704/b176704.txt">Table of n, a(n) for n = 1..1000</a>

%e a(1)=7 because are 7 twin primes (3,5,7,11,13,17,19) between non-twin prime(1)=2 and non-twin prime(2)=23.

%p From _R. J. Mathar_, Apr 27 2010: (Start)

%p isA001097 := proc(n) isprime(n) and ( isprime(n+2) or isprime(n-2) ); end proc:

%p A001097 := proc(n) option remember; if n =1 then 3; else for a from procname(n-1)+2 by 2 do if isA001097(a) then return a; end if; end do: end if; end proc:

%p A007510 := proc(n) option remember; if n <= 2 then op(n,[2,23]) ; else for a from procname(n-1)+2 by 2 do if isprime(a) and not isprime(a+2) and not isprime(a-2) then return a; end if; end do: end if; end proc:

%p A176704 := proc(n) local a,p ; a := 0 ; for p from A007510(n)+1 to A007510(n+1)-1 do if isA001097(p) then a := a+1 ; end if; end do: return a; end proc:

%p seq(A176704(n),n=1..120) ; (End)

%t Which[#=={0},Nothing,#[[1]]==1,Total[#],True,PadRight[{},Length[ #]- 1,0]]&/@Split[Table[If[AnyTrue[p+{2,-2},PrimeQ],1,0],{p,Prime[ Range[ 300]]}]]//Flatten (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Jul 13 2021 *)

%Y Cf. A001097, A007510.

%K nonn

%O 1,1

%A _Juri-Stepan Gerasimov_, Apr 24 2010

%E Corrected (a(21)=4 removed) by _R. J. Mathar_, Apr 27 2010