Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #14 Oct 16 2024 21:35:42
%S 0,0,2,2,4,4,0,3,2,6,0,4,12,12,0,5,4,16,4,0,6,12,0,7,3,6,18,4,24,3,9,
%T 6,24,0,8,2,8,16,32,24,0,9,18,36,8,24,0,10,0,11,4,28,24,0,12,48,0,13,
%U 12,0,14,0,15,5,10,20,6,30,9,27,4,32,64,10,30,60,14
%N a(0) = 0. For n >= 0, if a(n-1) is a novel term, a(n) = a(a(n-1)). If a(n-1) > 0 has been seen k(>1) times, a(n) = k*a(n-1), unless k*a(n-1) > n, in which case a(n) = 0. If a(n-1) = 0 has been seen k(>1) times, a(n) = k.
%C It seems that a(n) <= n with equality (in first 2^24 terms) only for n = 0,2,4,12,200, 216, 360, 2646.
%C 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).
%H Michael De Vlieger, <a href="/A376908/b376908.txt">Table of n, a(n) for n = 0..10000</a>
%H Michael De Vlieger, <a href="/A376908/a376908.png">Log log scatterplot of a(n)</a> n = 0..2^20, showing a(n) = 0 instead as a(n) = 1/2 in red for visibility.
%e a(0) = 0 a novel term, implies a(1) = a(a(0)) = a(0) = 0.
%e Now we have a(0) = a(1) = 0, so k = 2, which from the definition means a(2) = 2.
%e a(2) = 2 is a novel term so a(3) = a(a(2)) = a(2) = 2.
%e Because 2 has occurred twice we have a(4) = 2*2 = 4.
%e a(4) = 4 is a novel term so a(5) = a(a(4)) = a(4) = 4, the second occurrence of 4.
%e Since 2*4 = 8 exceeds 6, the index of the next term we invoke the 0 clause so a(6) = 0.
%e Now 0 has occurred three times, so a(7) = 3, a novel term making a(8) = a(a(3)) = 2.
%t nn = 120; c[_] := 0; j = a[0] = 0;
%t Do[If[c[j] == 0,
%t k = a[j],
%t If[j == 0,
%t k = c[0] + 1,
%t If[# > n, k = 0, k = #] &[j*(c[j] + 1)] ] ];
%t c[j]++; Set[{a[n], j}, {k, k}], {n, nn}];
%t Array[a, nn, 0] (* _Michael De Vlieger_, Oct 10 2024 *)
%Y Cf. A377027.
%K nonn
%O 0,3
%A _David James Sycamore_, Oct 08 2024
%E More terms from _Michael De Vlieger_, Oct 10 2024