%I #42 Mar 22 2023 12:51:15
%S 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,
%T 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,
%U 9,15,9,13,14,7,15,9,12,14,15,5,13,12,6,12,9,15
%N 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).
%H Michael S. Branicky, <a href="/A361199/b361199.txt">Table of n, a(n) for n = 1..10000</a>
%e a(10) = 3 because three primes result from the adding up process, visualized below. These are 2, 7 and 17.
%e . Prime P/ Prime
%e a(1) a(2) a(3) a(4) a(5) a(6) a(7) a(8) a(9) Composite C Count
%e .
%e 2 = 2 P 1
%e 2 + 2 = 4 C 0
%e 3 + 2 + 2 = 7 P 1
%e 1 + 3 + 2 + 2 = 8 C 0
%e 2 + 1 + 3 + 2 + 2 = 10 C 0
%e 2 + 2 + 1 + 3 + 2 + 2 = 12 C 0
%e 2 + 2 + 2 + 1 + 3 + 2 + 2 = 14 C 0
%e 2 + 2 + 2 + 2 + 1 + 3 + 2 + 2 = 16 C 0
%e 1 + 2 + 2 + 2 + 2 + 1 + 3 + 2 + 2 = 17 P 1
%e + _____
%e a(10) = 3
%e .
%p A[1]:= 1: A[2]:= 2: S:= [0,1,3]:
%p for n from 3 to 100 do
%p A[n]:= nops(select(isprime, map(t -> S[n]-t, S[1..n-1])));
%p S:= [op(S),A[n]+S[-1]]
%p od:
%p seq(A[i],i=1..100); # _Robert Israel_, Mar 22 2023
%t 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 *)
%o (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
%o (Python)
%o from sympy import isprime
%o from itertools import islice
%o def agen(): # generator of terms
%o an, sums = 2, [1]
%o yield 1
%o while True:
%o yield an
%o sums = [s + an for s in sums] + [an]
%o an = sum(1 for s in sums if isprime(s))
%o print(list(islice(agen(), 80))) # _Michael S. Branicky_, Mar 22 2023
%Y Cf. A000040, A361231, A361178.
%K nonn
%O 1,2
%A _Tamas Sandor Nagy_, Mar 04 2023