login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A062022 a(n) = Sum_{k=1..n} Sum_{j=1..k} (prime(k) - prime(j))^2. 3

%I #13 May 05 2022 04:41:52

%S 0,1,14,59,256,581,1298,2287,4004,7329,11338,17915,26660,36637,49406,

%T 67239,91252,117585,151730,191819,235112,289013,350842,425919,521300,

%U 628001,740666,865899,997744,1143501,1345454,1565639,1815068,2074761

%N a(n) = Sum_{k=1..n} Sum_{j=1..k} (prime(k) - prime(j))^2.

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

%F From _G. C. Greubel_, May 04 2022: (Start)

%F a(n) = a(n-1) + n*prime(n)^2 + Sum_{k=1..n} prime(k)*(prime(k) - 2*prime(n)), with a(0) = a(1) = 0.

%F a(n) = n*Sum_{j=1..n} prime(j)^2 - (Sum_{j=1..n} prime(j))^2 = n*A024450(n) - A007504(n)^2. (End)

%e a(3) = (5-2)^2 + (5-3)^2 + (3-2)^2 = 14, sum of the squared differences of all pairs of the first 3 primes.

%p A062022 := proc(n)

%p local a,i,j ;

%p a := 0 ;

%p for j from 1 to n do

%p for i from 1 to j-1 do

%p a := a+(ithprime(j)-ithprime(i))^2 ;

%p end do:

%p end do:

%p a ;

%p end proc:

%p seq(A062022(n), n=1..10); # _R. J. Mathar_, Oct 03 2014

%t a[n_]:= a[n]= n*Sum[Prime[k]^2, {k,n}] - (Sum[Prime[j], {j,n}])^2;

%t Table[a[n], {n, 50}] (* _G. C. Greubel_, May 04 2022 *)

%o (SageMath)

%o @CachedFunction

%o def a(n): return n*sum(nth_prime(j)^2 for j in (1..n)) - (sum(nth_prime(j) for j in (1..n)))^2

%o [a(n) for n in (1..50)] # _G. C. Greubel_, May 04 2022

%Y Cf. A000040, A007504, A024450, A062020, A062021.

%K nonn

%O 1,3

%A _Amarnath Murthy_, Jun 02 2001

%E More terms from _Matthew Conroy_, Jun 11 2001

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 23:40 EDT 2024. Contains 371798 sequences. (Running on oeis4.)