cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A104589 #34 Jun 03 2024 08:53:08
%S A104589 1,2,5,13,34,55,76,97,215,333,451,569,1256,1943,2630,3317,4004,4691,
%T A104589 10069,25516,40963,56410,71857,87304,102751,118198,133645,149092,
%U A104589 164539,179986,195433,210880,226327,241774,257221,529889,802557,1075225
%N 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).
%C A104589 By Dirichlet's Theorem there are an infinite number of primes in this sequence.
%H A104589 Michel Marcus, <a href="/A104589/b104589.txt">Table of n, a(n) for n = 1..2000</a>
%F A104589 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
%e A104589 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.
%t A104589 f[lst_] := Append[lst, Last@ lst + Plus @@ Select[lst, (PrimeQ@ # || # == 1) &]]; Nest[f, {1}, 38] (* _Robert G. Wilson v_, Jul 02 2007 *)
%o A104589 (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
%o A104589 (Python)
%o A104589 from sympy import isprime
%o A104589 from itertools import islice
%o A104589 def A104589_gen(): # generator of terms
%o A104589     a, b = 1, 1
%o A104589     while True:
%o A104589         yield a
%o A104589         a += b
%o A104589         b += a if isprime(a) else 0
%o A104589 A104589_list = list(islice(A104589_gen(),50)) # _Chai Wah Wu_, Jun 03 2024
%Y A104589 Cf. A008578.
%K A104589 nonn
%O A104589 1,2
%A A104589 _Leroy Quet_, Jun 12 2007
%E A104589 More terms from _Robert G. Wilson v_, Jul 02 2007