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”).

A104589
a(1)=1. a(n) = a(n-1) + (sum of terms, from among terms a(1) through a(n-1), which are prime or 1).
4
1, 2, 5, 13, 34, 55, 76, 97, 215, 333, 451, 569, 1256, 1943, 2630, 3317, 4004, 4691, 10069, 25516, 40963, 56410, 71857, 87304, 102751, 118198, 133645, 149092, 164539, 179986, 195433, 210880, 226327, 241774, 257221, 529889, 802557, 1075225
OFFSET
1,2
COMMENTS
By Dirichlet's Theorem there are an infinite number of primes in this sequence.
LINKS
FORMULA
a(n) = 3*a(n-1) - a(n-2) if a(n-1) is prime, else a(n) = 2*a(n-1) - a(n-2) for n>3. - John Tyler Rascoe, Jul 20 2022
EXAMPLE
The noncomposites among the first 8 terms of the sequence are 1, 2, 5, 13 and 97. The sum of these is 1+2+5+13+97 = 118. So a(9) = a(8) + 118 = 215.
MATHEMATICA
f[lst_] := Append[lst, Last@ lst + Plus @@ Select[lst, (PrimeQ@ # || # == 1) &]]; Nest[f, {1}, 38] (* Robert G. Wilson v, Jul 02 2007 *)
PROG
(PARI) lista(nn) = my(va = vector(nn), s = 1); va[1] = 1; for (n=2, nn, va[n] = va[n-1] + s; if (isprime(va[n]), s += va[n]); ); va; \\ Michel Marcus, Jul 21 2022
(Python)
from sympy import isprime
from itertools import islice
def A104589_gen(): # generator of terms
a, b = 1, 1
while True:
yield a
a += b
b += a if isprime(a) else 0
A104589_list = list(islice(A104589_gen(), 50)) # Chai Wah Wu, Jun 03 2024
CROSSREFS
Cf. A008578.
Sequence in context: A271940 A273721 A112841 * A154101 A122024 A252932
KEYWORD
nonn
AUTHOR
Leroy Quet, Jun 12 2007
EXTENSIONS
More terms from Robert G. Wilson v, Jul 02 2007
STATUS
approved