OFFSET
1,3
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..1000
FORMULA
From G. C. Greubel, May 04 2022: (Start)
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.
EXAMPLE
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.
MAPLE
A062022 := proc(n)
local a, i, j ;
a := 0 ;
for j from 1 to n do
for i from 1 to j-1 do
a := a+(ithprime(j)-ithprime(i))^2 ;
end do:
end do:
a ;
end proc:
seq(A062022(n), n=1..10); # R. J. Mathar, Oct 03 2014
MATHEMATICA
a[n_]:= a[n]= n*Sum[Prime[k]^2, {k, n}] - (Sum[Prime[j], {j, n}])^2;
Table[a[n], {n, 50}] (* G. C. Greubel, May 04 2022 *)
PROG
(SageMath)
@CachedFunction
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
[a(n) for n in (1..50)] # G. C. Greubel, May 04 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Jun 02 2001
EXTENSIONS
More terms from Matthew Conroy, Jun 11 2001
STATUS
approved