A293703 a(n) is the length of the longest palindromic subsequence in the first differences of the list of the first n negative and positive roots of floor(tan(k))=1.
1, 3, 5, 7, 9, 11, 13, 15, 15, 17, 17, 19, 19, 21, 21, 23, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117
Offset: 1
Keywords
Examples
For n = 1, the roots are -18, 1; the first differences are 19; the longest palindrome is 19; so a(n) = 1. For n = 2, the roots are -21, -18, 1, 4; the first differences are 3, 19, 3; the longest palindrome is 3, 19, 3; so a(n) = 3. For n = 8, the roots are -87, -84, -65, -62, -43, -40, -21, -18, 1, 4, 23, 26, 45, 48, 67, 70; the first differences are 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3; the longest palindrome is 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3; so a(n) = 15. For n = 9, the roots are -90, -87, -84, -65, -62, -43, -40, -21, -18, 1, 4, 23, 26, 45, 48, 67, 70, 89; first differences are 16, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19; the longest palindrome is 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3; so a(n) = 15.
Links
- V.J. Pohjola, Table of n, a(n) for n = 1..3001
- V.J. Pohjola, Line plot for n=1...20
- V.J. Pohjola, Line plot for n=1...200
- V.J. Pohjola, Line plot for n=1...3000
Programs
-
Mathematica
rootsA = {}; Do[ If[Floor[Tan[i]] == 1, AppendTo[rootsA, i]], {i, -10^5, 10^5}] lenN = Length[Select[rootsA, # < 0 &]] r = 200; roots = rootsA[[lenN - r ;; lenN + r + 1]] diff = Differences[roots] center = (Length[diff] + 1)/2; kmax = (Length[diff] + 1)/2 - 1; pals = {}; lenpals = {}; lenpal = 1; Do[diffk = diff[[center - k ;; center + k]]; lendiffk = Length[diffk]; w = 3; lenpal = lenpal + 2; (Label[alku]; w = w - 1; pmax = lendiffk - lenpal - (w - 1); t = Table[diffk[[p ;; lenpal + w + p - 1]], {p, 1, pmax}]; s = Select[t, # == Reverse[#] &]; If[s != {}, Goto[end], Goto[alku]]; Label[end]); AppendTo[pals, First[s]]; AppendTo[lenpals, Length[Flatten[First[s]]]]; lenpal = Length[Flatten[First[s]]], {k, 0, kmax}] lenpals (*a[n]=lenpals[[n]]*)
Comments