%I #43 Jan 06 2024 10:19:16
%S 1,1,2,2,2,3,3,3,3,4,4,4,3,2,3,2,3,3,3,4,3,5,4,3,4,3,3,5,3,3,6,3,3,7,
%T 4,3,8,5,3,9,6,4,3,3,3,7,3,3,4,3,4,3,4,3,6,3,5,3,6,2,3,4,3,7,3,5,3,4,
%U 3,5,3,6,4,3,4,3,6,3,6,4,3,5,3,5,3,4,3
%N a(n) is the length of the longest arithmetic progression ending at a(n-1); a(1)=1.
%C Progressions are terms at indices which are in arithmetic progression and with values which are in arithmetic progression too.
%C In the first 10^6 terms, no 2's occur after a(60) and no 3's occur after a(2746). Can it be proved that no more will occur after these values? For any k in the sequence, is there a term where k occurs for the final time?
%C This sequence is unbounded (this is a consequence of Van der Waerden's theorem). - _Rémy Sigrist_, May 14 2023
%H Samuel Harkness, <a href="/A362881/b362881.txt">Table of n, a(n) for n = 1..10000</a>
%H Samuel Harkness, <a href="/A362881/a362881.m.txt">MATLAB program</a>.
%H OEIS Wiki, <a href="/wiki/Ordinal_transform">Ordinal transform</a>.
%H Neal Gersh Tolunsky, <a href="/A362881/a362881_1.png">Graph of the ordinal transform of the first 10000 terms</a>, with lines labeled by corresponding values of this sequence.
%H Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/vanderWaerdensTheorem.html">Van der Waerden's Theorem</a>.
%e For n = 13, the longest arithmetic progression ending at a(12) is {a(4), a(8), a(12)} = {2, 3, 4}, which has length 3, so a(13) = 3.
%e For n = 28, the longest arithmetic progression ending at a(27) is {a(15), a(18), a(21), a(24), a(27)} = {3, 3, 3, 3, 3}, which has length 5, so a(28) = 5.
%t a[nmax_Integer] := Module[{K, r, f, d}, K = ConstantArray[0, nmax]; K[[1 ;; 2]] = {1, 1}; For[n = 3, n <= nmax, n++, r = 1; For[b = 1, b <= n - 2, b++, d = K[[n - 1 - b]] - K[[n - 1]]; f = 2; While[n - 1 - f*b > 0 && K[[n - 1 - f*b]] - K[[n - 1 - (f - 1)*b]] == d, f = f + 1;]; If[f > r, r = f];]; K[[n]] = r;]; K]; a[87] (* _Robert P. P. McKone_, Aug 24 2023 *)
%o (MATLAB) See Links section.
%Y Cf. A308638, A362909 (indices of record highs).
%K nonn
%O 1,3
%A _Samuel Harkness_, May 07 2023