OFFSET
1,3
LINKS
G. C. Greubel, Table of n, a(n) for n = 1..1000
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