login
A062020
a(n) = Sum_{i=1..n} Sum_{j=1..i} (prime(i) - prime(j)).
6
0, 1, 6, 17, 44, 81, 142, 217, 324, 485, 666, 913, 1208, 1529, 1906, 2373, 2936, 3533, 4238, 5019, 5840, 6787, 7822, 8995, 10360, 11825, 13342, 14967, 16648, 18445, 20662, 23003, 25536, 28135, 31074, 34083, 37308, 40755, 44354, 48187, 52260
OFFSET
1,3
LINKS
FORMULA
a(n) = a(n-1) + n*prime(n) - Sum_{i = 1..n} prime(i), with a(0) = 0.
a(n) = 2*a(n-1) - a(n-2) + (n-1)*(prime(n) - prime(n-1)), with a(1) = 0, a(2) = 1.
a(n) = Sum_{j=1..n} (2*j - (n+1))*prime(j) = 2*A014285(n) - (n+1)*A007504(n). - G. C. Greubel, May 04 2022
EXAMPLE
a(3) = (5-2) + (5-3) + (3-2) = 6.
MATHEMATICA
a[n_]:= a[n]= If[n<3, (n-1), 2*a[n-1] -a[n-2] +(n-1)*(Prime[n] -Prime[n-1])];
Table[a[n], {n, 50}] (* G. C. Greubel, May 04 2022 *)
PROG
(SageMath)
@CachedFunction
def a(n): # A062020
if (n<3): return (n-1)
else: return 2*a(n-1) - a(n-2) + (n-1)*(nth_prime(n) - nth_prime(n-1))
[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 Larry Reeves (larryr(AT)acm.org), Jun 05 2001
Name edited by G. C. Greubel, May 04 2022
STATUS
approved