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.

A385986 a(1) = 2, and for any n > 1, a(n) is the largest k < n such that a(1) + ... + a(k) is prime.

Original entry on oeis.org

2, 1, 2, 3, 3, 5, 5, 5, 5, 9, 9, 9, 9, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 65, 65, 65
Offset: 1

Views

Author

Rémy Sigrist, Jul 14 2025

Keywords

Comments

In other words: a(1) = 2, and for any n > 0, if a(1) + ... + a(n) is prime then a(n+1) = n, otherwise a(n+1) = a(n).
This sequence is unbounded: for any n > 1, let P = a(1) + ... + a(a(n)); P is prime and a(a(n)+1) = a(n); as P > a(n), P and a(n) are coprime, hence, by Dirichlet's theorem on arithmetic progressions, P + k*a(n) is prime for some minimal k > 0, and a(a(n)+k+1) = a(n)+k > a(n).

Examples

			Sequence begins:
  n   a(n)  a(1)+...+a(n)  Prime?
  --  ----  -------------  ------
   1     2              2  Yes
   2     1              3  Yes
   3     2              5  Yes
   4     3              8  No
   5     3             11  Yes
   6     5             16  No
   7     5             21  No
   8     5             26  No
   9     5             31  Yes
  10     9             40  No
  11     9             49  No
  12     9             58  No
  13     9             67  Yes
  14    13             80  No
		

Crossrefs

See A385988 and A386369 for similar sequences.
Cf. A385987 (corresponding prime numbers).

Programs

  • Mathematica
    v = 2;t = 0;values={};Do[AppendTo[values,v];t+=v;If[PrimeQ[t],v=n],{n, 1, 68}];values (* James C. McMahon, Jul 22 2025 *)
  • PARI
    { v = 2; t = 0; for (n = 1, 68, print1 (v", "); if (isprime(t += v), v = n);); }