OFFSET
0,3
COMMENTS
It seems that a(n) <= n with equality (in first 2^24 terms) only for n = 0,2,4,12,200, 216, 360, 2646.
a(n-1) = 0 is followed by k, the number of zeros seen so far, (rather than k*a(n-1) as for nonzero terms), otherwise the sequence would contain only zeros. The a(n) = 0 clause is necessary to ensure continuation of the sequence at points, since without it there would be occasions where a(n) = a(a(m)) but a(m) is not yet defined. The first such instance follows a(5) = 4, the second time 4 appears, upon which we would have a(6) = 2*4 = 8, a novel term so a(7) = a(a(8)), but a(8) is not yet defined. By setting a(6) = 0 the sequence can continue (see Example).
LINKS
Michael De Vlieger, Table of n, a(n) for n = 0..10000
Michael De Vlieger, Log log scatterplot of a(n) n = 0..2^20, showing a(n) = 0 instead as a(n) = 1/2 in red for visibility.
EXAMPLE
a(0) = 0 a novel term, implies a(1) = a(a(0)) = a(0) = 0.
Now we have a(0) = a(1) = 0, so k = 2, which from the definition means a(2) = 2.
a(2) = 2 is a novel term so a(3) = a(a(2)) = a(2) = 2.
Because 2 has occurred twice we have a(4) = 2*2 = 4.
a(4) = 4 is a novel term so a(5) = a(a(4)) = a(4) = 4, the second occurrence of 4.
Since 2*4 = 8 exceeds 6, the index of the next term we invoke the 0 clause so a(6) = 0.
Now 0 has occurred three times, so a(7) = 3, a novel term making a(8) = a(a(3)) = 2.
MATHEMATICA
nn = 120; c[_] := 0; j = a[0] = 0;
Do[If[c[j] == 0,
k = a[j],
If[j == 0,
k = c[0] + 1,
If[# > n, k = 0, k = #] &[j*(c[j] + 1)] ] ];
c[j]++; Set[{a[n], j}, {k, k}], {n, nn}];
Array[a, nn, 0] (* Michael De Vlieger, Oct 10 2024 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
David James Sycamore, Oct 08 2024
EXTENSIONS
More terms from Michael De Vlieger, Oct 10 2024
STATUS
approved