[go: up one dir, main page]

login
Related to cumulative number of non-twin primes.
2

%I #17 May 14 2016 13:46:04

%S 0,0,0,1,1,2,2,3,4,4,5,6,6,7,8,9,9,10,11,11,12,13,14,15,16,16,17,17,

%T 18,19,20,21,21,22,22,23,24,25,26,27,27,28,28,29,29,30,31,32,32,33,34,

%U 34,35,36,37,38,38,39,40,40,41,42,43,43,44,45,46,47,47,48,49,50

%N Related to cumulative number of non-twin primes.

%H Robert Israel and Paul Nanninga, <a href="/A074239/b074239.txt">Table of n, a(n) for n = 0..10000</a> (terms up to a(100) from Paul Nanninga)

%F Take the sequence of odd primes op(n); set a(0) = 0; if op(n+1)-op(n)=2 a(n+1) = a(n), if op(n+1)-op(n) > 2 a(n+1) = a(n) + 1.

%p N:= 100: # to get a(0) to a(N)

%p P:= [seq(ithprime(i),i=2..N+2)]:

%p ListTools:-PartialSums([0,seq(`if`(P[i]-P[i-1]=2,0,1),i=2..N+1)]); # _Robert Israel_, May 13 2016

%t Accumulate@ Table[If[Prime@ n - Prime[n - 1] == 2, 0, 1], {n, 2, 120}] - 1 (* _Michael De Vlieger_, May 13 2016, after _Robert Israel_ *)

%o (PARI) op(n) = prime(n+1);

%o lista(nn) = {my(x=0); for (n=1, nn, print1(x, ", "); if ((op(n+1) - op(n)) > 2, x++););} \\ _Michel Marcus_, May 13 2016

%Y Cf. A065091 (odd primes), A007510 (non-twin primes).

%K easy,nonn

%O 0,6

%A Rudi Huysmans (rudi.huysmans(AT)pandora.be), Sep 18 2002