login
A374966
a(n) = 0 if n has appeared in the sequence before, otherwise a(n) = a(n-1) + n. Start with a(0) = 0.
3
0, 1, 3, 0, 4, 9, 15, 22, 30, 0, 10, 21, 33, 46, 60, 0, 16, 33, 51, 70, 90, 0, 0, 23, 47, 72, 98, 125, 153, 182, 0, 31, 63, 0, 34, 69, 105, 142, 180, 219, 259, 300, 342, 385, 429, 474, 0, 0, 48, 97, 147, 0, 52, 105, 159, 214, 270, 327, 385, 444, 0, 61, 123, 0, 64, 129, 195, 262, 330, 0, 0
OFFSET
0,3
COMMENTS
The sequence seems to grow linearly. The average distance between zeros in the sequence appears to converge to about 7.42.
The set of numbers appearing in this sequence is the union of {A375060(n)} and {A375060(n) + 1}. - Yifan Xie, Apr 09 2025
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..16384 (terms 0..9999 from Bryle Morga).
Michael De Vlieger, Log log scatterplot of a(n), n = 0..2^20, showing zeros instead as 1/2 in red, otherwise blue.
EXAMPLE
a(1) = a(0) + 1 = 1.
a(2) = a(1) + 2 = 3.
a(3) = 0 because a(2) = 3.
MAPLE
A374966:=proc(n) option remember; local l, p, s;
if n=0 then [0, [0]] else p:=procname(n-1); s:=p[1]; l:=p[2];
`if`(member(n, l), [0, l], [s+n, [op(l), s+n]]) fi
end:
seq(A374966(n)[1], n=0..70); # Felix Huber, Nov 06 2025
MATHEMATICA
a={0}; For[n=1, n<=70, n++, If[MemberQ[a, n], AppendTo[a, 0], AppendTo[a, Last[a]+n]]]; a (* Stefano Spezia, Jul 26 2024 *)
Fold[If[MemberQ[#1, #2], Append[#1, 0], Append[#1, Last[#1] + #2]] &, {0}, Range @ 10^5] (* Mikk Heidemaa, Oct 05 2024 *)
PROG
(Python)
from itertools import count, islice
def agen(): # generator of terms
seen, an = {0}, 0
for n in count(1):
yield an
an = 0 if n in seen else an + n
seen.add(an)
print(list(islice(agen(), 71))) # Michael S. Branicky, Jul 25 2024
CROSSREFS
Sequence in context: A389557 A072329 A068630 * A309764 A079406 A378505
KEYWORD
nonn,easy,nice
AUTHOR
Bryle Morga, Jul 25 2024
STATUS
approved