A293705 a(n) is the shift of the longest palindromic subsequence in the first n terms of A293699.
0, -1, 0, -1, 0, -1, 0, -1, -2, -3, -4, -5, -6, 6, 5, 7, 6, 5, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5
Offset: 1
Keywords
Examples
For n = 1, differences = 3; longest palindrome = 3; a(1) = 0 - 0 = 0. For n = 2, differences = 3, 19; longest palindrome = 3; a(2) = 0 - 1 = -1. For n = 14, differences = 3, 19, 3, 19, 3, 19, 3, 3, 16, 3, 3, 16, 3, 3; longest palindrome = 3, 3, 16, 3, 3, 16, 3, 3; a(14) = 6 - 0 = 6.
Links
- V.J. Pohjola, Table of n, a(n) for n = 1..10000
- V.J. Pohjola, Line plot for n=1...10000
- V.J. Pohjola, Line plot for n=1...100
Programs
-
Mathematica
rootsn = Flatten[Position[Table[Floor[Tan[-i]], {i, 1, 10^4}], 1]]; difn = Differences[rootsn]; ldn = Length[difn]; kmax = 500; palsn = {}; lenpalsn = {0}; shiftn = {}; posn = {}; Do[diffin = difn[[1 ;; k]]; lendiffin = Length[diffin]; pmax = k - Last[lenpalsn]; t = Table[difn[[p ;; k]], {p, 1, pmax}]; sn = Flatten[Select[t, # == Reverse[#] &]]; If[sn == {}, AppendTo[palsn, Last[palsn]] && AppendTo[lenpalsn, Last[lenpalsn]], AppendTo[palsn, sn] && AppendTo[lenpalsn, Length[Flatten[sn]]]]; AppendTo[posn, Position[t, Last[palsn]]]; pp = Last[Flatten[posn]] - 1; qq = lendiffin - (pp + Last[lenpalsn]); AppendTo[shiftn, pp - qq], {k, 1, kmax}]; shiftn (*a(n)=shiftn[[n]]*)
Comments