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.

This page as a plain text file.
%I A385986 #12 Jul 24 2025 09:40:07
%S A385986 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,
%T A385986 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
%U A385986 23,23,23,53,53,53,53,53,53,53,53,53,53,53,53,65,65,65
%N A385986 a(1) = 2, and for any n > 1, a(n) is the largest k < n such that a(1) + ... + a(k) is prime.
%C A385986 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).
%C A385986 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).
%H A385986 Rémy Sigrist, <a href="/A385986/b385986.txt">Table of n, a(n) for n = 1..10000</a>
%e A385986 Sequence begins:
%e A385986   n   a(n)  a(1)+...+a(n)  Prime?
%e A385986   --  ----  -------------  ------
%e A385986    1     2              2  Yes
%e A385986    2     1              3  Yes
%e A385986    3     2              5  Yes
%e A385986    4     3              8  No
%e A385986    5     3             11  Yes
%e A385986    6     5             16  No
%e A385986    7     5             21  No
%e A385986    8     5             26  No
%e A385986    9     5             31  Yes
%e A385986   10     9             40  No
%e A385986   11     9             49  No
%e A385986   12     9             58  No
%e A385986   13     9             67  Yes
%e A385986   14    13             80  No
%t A385986 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 *)
%o A385986 (PARI) { v = 2; t = 0; for (n = 1, 68, print1 (v", "); if (isprime(t += v), v = n);); }
%Y A385986 See A385988 and A386369 for similar sequences.
%Y A385986 Cf. A385987 (corresponding prime numbers).
%K A385986 nonn,easy
%O A385986 1,1
%A A385986 _Rémy Sigrist_, Jul 14 2025