OFFSET
1,1
EXAMPLE
a(3) = 2+3+5+7 = 17 because 17 <= prime(3)^2 < 28 = 2+3+5+7+11.
a(4) = 2+3+5+7+11+13 = 41 because 41 <= prime(4)^2 < 58 = 2+3+5+7+11+13+17.
MATHEMATICA
Table[k=1; While[(s=Sum[Prime@i, {i, ++k}])<Prime@n^2]; s-Prime@k, {n, 50}] (* Giorgos Kalogeropoulos, Jul 06 2021 *)
PROG
(PARI) a(n) = my(s=0, p=2); while (s+p <= prime(n)^2, s += p; p = nextprime(p+1)); s; \\ Michel Marcus, Jul 05 2021
(Python)
from sympy import prime, nextprime
def a(n):
p, s, lim = 1, 0, prime(n)**2
while s <= lim: p = nextprime(p); s += p
return s - p
print([a(n) for n in range(1, 51)]) # Michael S. Branicky, Jul 05 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
Gil Broussard, Jul 05 2021
STATUS
approved