login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A361199
a(1) = 1, a(2) = 2; for n >=3, a(n) is the number of primes in a(n-1), a(n-1) + a(n-2), ..., a(n-1) + a(n-2) + ... + a(1).
3
1, 2, 2, 2, 2, 1, 3, 2, 2, 3, 7, 2, 3, 7, 3, 5, 3, 7, 3, 7, 4, 4, 1, 10, 9, 2, 5, 7, 6, 4, 4, 5, 11, 8, 6, 2, 4, 7, 15, 6, 5, 10, 12, 9, 7, 11, 7, 14, 9, 8, 7, 16, 11, 9, 11, 10, 8, 7, 11, 13, 13, 9, 15, 9, 13, 14, 7, 15, 9, 12, 14, 15, 5, 13, 12, 6, 12, 9, 15
OFFSET
1,2
LINKS
EXAMPLE
a(10) = 3 because three primes result from the adding up process, visualized below. These are 2, 7 and 17.
. Prime P/ Prime
a(1) a(2) a(3) a(4) a(5) a(6) a(7) a(8) a(9) Composite C Count
.
2 = 2 P 1
2 + 2 = 4 C 0
3 + 2 + 2 = 7 P 1
1 + 3 + 2 + 2 = 8 C 0
2 + 1 + 3 + 2 + 2 = 10 C 0
2 + 2 + 1 + 3 + 2 + 2 = 12 C 0
2 + 2 + 2 + 1 + 3 + 2 + 2 = 14 C 0
2 + 2 + 2 + 2 + 1 + 3 + 2 + 2 = 16 C 0
1 + 2 + 2 + 2 + 2 + 1 + 3 + 2 + 2 = 17 P 1
+ _____
a(10) = 3
.
MAPLE
A[1]:= 1: A[2]:= 2: S:= [0, 1, 3]:
for n from 3 to 100 do
A[n]:= nops(select(isprime, map(t -> S[n]-t, S[1..n-1])));
S:= [op(S), A[n]+S[-1]]
od:
seq(A[i], i=1..100); # Robert Israel, Mar 22 2023
MATHEMATICA
a[1] = 1; a[2] = 2; a[n_] := a[n] = Count[Accumulate[Table[a[i], {i, n - 1, 1, -1}]], _?PrimeQ]; Array[a, 100] (* Amiram Eldar, Mar 04 2023 *)
PROG
(PARI) lista(nn) = my(va=vector(nn)); va[1] = 1; va[2] = 2; for (n=3, nn, my(s=0, nb=0); for (k=1, n-1, s += va[n-k]; if (isprime(s), nb++); ); va[n] = nb; ); va; \\ Michel Marcus, Mar 04 2023
(Python)
from sympy import isprime
from itertools import islice
def agen(): # generator of terms
an, sums = 2, [1]
yield 1
while True:
yield an
sums = [s + an for s in sums] + [an]
an = sum(1 for s in sums if isprime(s))
print(list(islice(agen(), 80))) # Michael S. Branicky, Mar 22 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Tamas Sandor Nagy, Mar 04 2023
STATUS
approved