OFFSET
1,1
LINKS
Hieronymus Fischer, Table of n, a(n) for n = 1..1000
FORMULA
EXAMPLE
a(1) = 5 because the first 2 primes are 2 and 3 and 2 + 3 = 5.
a(2) = 23 because the next 3 primes are 5, 7, 11, and they add up to 23.
a(3) = 101 because the next 5 primes are 13, 17, 19, 23, 29 which add up to 101.
a(4) = 311 because the next 7 primes are 31, 37, 41, 43, 47, 53, 59 and they add up to 311.
MATHEMATICA
Join[{5}, Total[Prime[Range[#[[1]]+1, #[[2]]]]]&/@Partition[ Accumulate[ Prime[ Range[40]]], 2, 1]] (* Harvey P. Dale, Oct 03 2013 *)
Module[{nn=33}, Total/@TakeList[Prime[Range[Total[Prime[Range[nn]]]]], Prime[ Range[ nn]]]] (* Requires Mathematica version 11 or later *) (* Harvey P. Dale, Mar 16 2018 *)
s = 0; Total[Table[s = s + 1; Prime[s], {j, 33}, {n, Prime[j]}], {2}] (* Horst H. Manninger, Jan 17 2019 *)
PROG
(PARI) s(n) = sum(k=1, n, prime(k)); \\ A007504
a(n) = s(s(n)) - s(s(n-1)); \\ Michel Marcus, Oct 12 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
Patrick De Geest, Oct 15 1998
STATUS
approved