login
Difference between partial sum of the first n primes and the first n even numbers greater than 0.
1

%I #14 Aug 20 2017 16:58:52

%S 0,-1,-2,-3,-2,-1,2,5,10,19,28,41,56,71,88,109,134,159,188,219,250,

%T 285,322,363,410,459,508,559,610,663,728,795,866,937,1016,1095,1178,

%U 1265,1354,1447,1544,1641,1746,1851,1958,2065,2182,2309,2438,2567,2698,2833,2968,3111,3258,3409,3564,3719,3878,4039,4200

%N Difference between partial sum of the first n primes and the first n even numbers greater than 0.

%H G. C. Greubel, <a href="/A135267/b135267.txt">Table of n, a(n) for n = 1..1000</a>

%F a(n) = A007504(n) - A002378(n). - _R. J. Mathar_, Sep 10 2016

%t Table[Sum[Prime[k], {k, 1, n}] - n*(n + 1), {n, 1, 50}] (* _G. C. Greubel_, Oct 08 2016 *)

%t With[{nn=70},#[[1]]-#[[2]]&/@Thread[{Accumulate[Prime[Range[ nn]]], Accumulate[ Range[2,2nn,2]]}]] (* _Harvey P. Dale_, Aug 20 2017 *)

%o (PARI) g(n) = for(x=1,n,y=sum(j=1,x,2*j);z=sum(j=1,x,prime(j));print1(z-y","))

%o (PARI) a(n)=my(s,k); forprime(p=2,, if(k++>n, break); s+=p); s-n*(n+1) \\ _Charles R Greathouse IV_, Oct 08 2016

%Y Cf. A002378, A007504.

%K sign,easy

%O 1,3

%A _Cino Hilliard_, Dec 02 2007