OFFSET
1,2
COMMENTS
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.
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.
The graph forms several near-linear lines. It appears that the distribution of "resets" to 1 doesn't diminish as the sequence progresses.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 1..10015
FORMULA
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).
a(n) = 1 iff n = 1 or n = A087128(k) + k + 1 for some k > 0. - Rémy Sigrist, Feb 13 2026
EXAMPLE
The terms and runs begin
n = 1 2 3 4 5 6 7 8 9 10 11 12 13
a(n) = 1, 2, 1, 3, 1, 4, 8, 13, 1, 7, 1, 8, 16, ...
step +1 +2 +3 +4 +5 +6 +7 +8
runs \--/ \--/ \---------/ \--/ \-------
MATHEMATICA
Module[{k = 0}, NestList[If[PrimeQ[#], 1, ++k + #] &, 1, 100]] (* Paolo Xausa, Feb 13 2026 *)
PROG
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Andrey Mateshko, Dec 24 2025
EXTENSIONS
More terms from Michel Marcus, Feb 13 2026
STATUS
approved
