%I #39 Feb 14 2026 10:21:29
%S 1,2,1,3,1,4,8,13,1,7,1,8,16,25,35,46,58,71,1,15,30,46,63,81,100,120,
%T 141,163,1,24,48,73,1,27,54,82,111,141,172,204,237,271,1,36,72,109,1,
%U 39,78,118,159,201,244,288,333,379,1,48,96,145,195,246,298,351,405,460,516,573,631,1
%N a(n) = 1 if n=1 or a(n-1) is prime; a(n) = a(n-1) + i otherwise, where i = n - r and r is the number of occurrences of 1 among terms a(1) to a(n-1).
%C Runs of growth from 1 up to a prime where each term adds +i for successive i = 1,2,3,... and those increments continue in each run.
%C During a "reset" from a prime back to 1, i does not increase. Thus, i only increases within runs so that i is smaller than n by the number of occurrences of 1 per the formula below.
%C The graph forms several near-linear lines. It appears that the distribution of "resets" to 1 doesn't diminish as the sequence progresses.
%H Rémy Sigrist, <a href="/A391972/b391972.txt">Table of n, a(n) for n = 1..10015</a>
%F a(n) = 1 if n=1 or a(n-1) is prime; a(n) = a(n-1) + i otherwise, where i = n - r and r is the number of occurrences of 1 among terms a(1) to a(n-1).
%F a(n) = 1 iff n = 1 or n = A087128(k) + k + 1 for some k > 0. - _Rémy Sigrist_, Feb 13 2026
%F a(A393398(n)) = A393386(n). - _Paolo Xausa_, Feb 13 2026
%e The terms and runs begin
%e n = 1 2 3 4 5 6 7 8 9 10 11 12 13
%e a(n) = 1, 2, 1, 3, 1, 4, 8, 13, 1, 7, 1, 8, 16, ...
%e step +1 +2 +3 +4 +5 +6 +7 +8
%e runs \--/ \--/ \---------/ \--/ \-------
%t Module[{k = 0}, NestList[If[PrimeQ[#], 1, ++k + #] &, 1, 100]] (* _Paolo Xausa_, Feb 13 2026 *)
%o (PARI) lista(nn) = my(list=List(), last=1); listput(list, last); for (n=2, nn, if (isprime(last), last=1, last = last + n - #select(x->(x==1), list)); listput(list, last);); Vec(list); \\ _Michel Marcus_, Dec 27 2025
%Y Cf. A087128, A393386, A393398.
%K nonn
%O 1,2
%A _Andrey Mateshko_, Dec 24 2025
%E More terms from _Michel Marcus_, Feb 13 2026