A362881 a(n) is the length of the longest arithmetic progression ending at a(n-1); a(1)=1.
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, 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, 3, 5, 3, 6, 4, 3, 4, 3, 6, 3, 6, 4, 3, 5, 3, 5, 3, 4, 3
Offset: 1
Keywords
Examples
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. 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.
Links
- Samuel Harkness, Table of n, a(n) for n = 1..10000
- Samuel Harkness, MATLAB program.
- OEIS Wiki, Ordinal transform.
- Neal Gersh Tolunsky, Graph of the ordinal transform of the first 10000 terms, with lines labeled by corresponding values of this sequence.
- Eric Weisstein's World of Mathematics, Van der Waerden's Theorem.
Programs
-
MATLAB
See Links section.
-
Mathematica
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 *)
Comments