%I #21 Aug 23 2023 08:45:53
%S 0,0,1,0,1,2,1,2,3,0,1,2,3,4,1,2,3,4,5,2,3,4,5,6,1,2,3,4,5,6,7,2,3,4,
%T 5,6,7,8,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,11,
%U 2,3,4,5,6,7,8,9,10,11,12,3,4,5,6,7,8,9
%N a(0) = 0. If a(n-1) is a novel term, a(n) = a(a(n-1)); otherwise a(n) is the number of distinct terms occurring prior to a(n-1) which are <= a(n-1).
%C The novel terms are all records so the records subsequence is A000027.
%C Following each record term r, the sequence resets to a(r) then increments to novel term r+1, which introduces a(r+1), and so on (compare with A002262, which resets to 0 after each record).
%C The proper subsequence {a(a(r))} is a copy of the original, which therefore is fractal.
%H Michael De Vlieger, <a href="/A364880/b364880.txt">Table of n, a(n) for n = 0..10353</a> (rows 0..150, flattened)
%H Michael De Vlieger, <a href="/A364880/a364880.png">Scatterplot of a(n)</a>, n = 0..119 showing the first terms in each row in red, and all other terms in dark blue, labeling these respectively in the same color so as to demonstrate T(n,1) = a(n-1), where T(n,1) is the first term of row n, and sequence a represents the flattened irregular table T.
%H Michael De Vlieger, <a href="/A364880/a364880_1.png">Scatterplot of a(n)</a>, n = 0..2047 with the same color approach used above, but only labeling T(n,1).
%e a(0) = 0 is a novel term, so a(1) = a(a(0)) = a(0) = 0.
%e a(2) = 1 because there is just one distinct prior term (0) which is <= 0.
%e Since a(2) = 1 is a novel term, a(3) = a(a(2)) = a(1) = a(0) = 0.
%e a(4) = 1 because a(3) = 0 is a repeat term and there is only one distinct term (0) <= 0.
%e The sequence can be represented as an irregular table in which each row starts with a record term, and ends with the first repeat of the same number. The first column is A000027, and the second column is the sequence itself:
%e The table starts:
%e 0, 0;
%e 1, 0, 1;
%e 2, 1, 2;
%e 3, 0, 1, 2, 3;
%e 4, 1, 2, 3, 4;
%e 5, 2, 3, 4, 5;
%e 6, 1, 2, 3, 4, 5, 6;
%e 7, 2, 3, 4, 5, 6, 7;
%e 8, 3, 4, 5, 6, 7, 8;
%e 9, 0, ...
%t nn = 120; a[0] = j = k = 0; r = -1; Do[If[j > r, k = a[j]; r = j, k++]; Set[{a[n], j}, {k, k}], {n, nn}]; Array[a, nn + 1, 0] (* _Michael De Vlieger_, Aug 14 2023 *)
%Y Cf. A000027, A002262.
%K nonn,easy,tabf
%O 0,6
%A _David James Sycamore_, Aug 11 2023