cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A293701 a(n) is the length of the longest palindromic subsequence in the first n terms of A293700.

Original entry on oeis.org

1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 47, 49
Offset: 1

Views

Author

V.J. Pohjola, Oct 16 2017

Keywords

Comments

If a(n + 1) > a(n) for some n, then A293700(n + 1) is in the longest palindrome. So to find a(n + 1) it suffices to check if A293700 is in the palindrome, which must be at least of length a(n). - David A. Corneth, Nov 25 2017
At points where a(n) = n, the whole sequence is a palindrome. For example at n=9105, the length of the longest palindrome a(9105) is 9105 (see A294923).

Examples

			For n = 1, roots = 1, 4; first differences = 3; longest palindrome = 3; a(n) = 1.
For n = 2, roots = 1, 4, 23; first differences = 3, 19; longest palindrome = 3; a(n) = 1.
For n = 3, roots = 1, 4, 23, 26; first differences = 3, 19, 3; longest palindrome = 3, 19, 3; a(n) = 3.
For n = 33, roots = 1, 4, 23, 26, 45, 48, 67, 70, 89, 92, 111, 114, 133, 136, 155, 158, 177, 180, 183, 199, 202, 205, 221, 224, 227, 243, 246, 249, 265, 268, 271, 290, 293, 312; first differences = 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 19, 3, 19; longest palindrome = 19, 3, 19, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 19, 3, 19; a(n) = 20.
		

Crossrefs

Programs

  • Mathematica
    rootsp = Flatten[Position[Table[Floor[Tan[i]], {i, 1, 10^4}], 1]];
    lrootsp = Length[rootsp];
    difp = Differences[rootsp];
    ldp = Length[difp];
    nmax = 200; palsp = {}; lenpalsp = {0};
    Do[diffip = difp[[1 ;; n]]; lendiffip = Length[diffip];
      pmax = n - Last[lenpalsp];
      t = Table[difp[[p ;; n]], {p, 1, pmax}];
      sp = Flatten[Select[t, # == Reverse[#] &]];
      If[sp == {},
       AppendTo[palsp, Last[palsp]] && AppendTo[lenpalsp, Last[lenpalsp]],
       AppendTo[palsp, sp] && AppendTo[lenpalsp, Length[Flatten[sp]]]], {n, 1, nmax}];
    Drop[lenpalsp,1](*a(n)=Drop[lenpalsp,1][[n]]*)
  • PARI
    firstsols(n) = {my(res = vector(n), i = 0, pi = [Pi, Pi], sols = [atan(1), atan(2)]); while(1, for(j = ceil(sols[1]), floor(sols[2]), i++; if(i>n, return(res)); res[i] = j); sols+=[Pi(), Pi()])} \\ A293698
    diff(v) = vector(#v-1,i,v[i+1]-v[i]);
    first(n) = {my(res = vector(n), m = 0, check = diff(firstsols(n+1))); for(i=1, n, for(j = 1, i - m, if(ispalindrome(check, j, i), m = i - j + 1; next(1))); res[i] = m); res}
    ispalindrome(v, {llim = 1}, {ulim = #v}) = {for(i=0, (ulim - llim) \ 2, if(v[llim + i]!=v[ulim - i], return(0))); 1} \\ David A. Corneth, Nov 25 2017
    
  • Scheme
    ;; This uses memoization-macro definec and assumes also that A293700 is available:
    (definec (A293701 n) (if (= 1 n) n (let outloop ((k n)) (cond ((<= k (A293701 (- n 1))) (A293701 (- n 1))) (else (let inloop ((i n)) (let ((low-ind (+ 1 (- n k) (- n i)))) (cond ((< i low-ind) (max k (A293701 (- n 1)))) ((not (= (A293700 i) (A293700 low-ind))) (outloop (- k 1))) (else (inloop (- i 1)))))))))))
    ;; Antti Karttunen, Nov 25 2017

A294924 Numbers n such that the whole sequence of the first n terms of A293699 is a palindrome.

Original entry on oeis.org

1, 3, 5, 7, 26, 63, 100, 137, 174, 211, 248, 285, 322, 359, 396, 433, 470, 507, 544, 581, 618, 655, 692, 729, 766, 803, 840, 877, 914, 951, 988, 1025, 1062, 1099, 1136, 1173, 1210, 1247, 1284, 1321, 1358, 1395, 1432, 1469, 1506, 1543, 1580, 1617, 1654, 1691, 1728, 1765, 1802, 1839, 1876, 1913, 1950, 1987, 2024, 2061, 2098, 2135
Offset: 1

Views

Author

V.J. Pohjola, Nov 11 2017

Keywords

Comments

A293699 are the first differences of A293751 which are the positive integers i such that floor(tan(-i))=1.
A293702 are the lengths of the longest palindromic subsequences in the first n terms of A293699.

Examples

			The first 7 terms of A293699 are (3, 19, 3, 19, 3, 19, 3) which is a palindromic sequence, so 7 is a term.
The first 8 terms of A293699 are (3, 19, 3, 19, 3, 19, 3, 3) which is not a palindromic sequence, so 8 is not a term.
The first 9 terms of A293699 are (3, 19, 3, 19, 3, 19, 3, 3, 16) which is not a palindromic sequence, so 9 is not a term.
The first 25 terms of A293699 are (3, 19, 3, 19, 3, 19, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 19, 3, 19, 3, 19) which is not a palindromic sequence, so 25 is not a term.
The first 26 terms of A293699 are (3, 19, 3, 19, 3, 19, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 16, 3, 3, 19, 3, 19, 3, 19, 3) which is a palindromic sequence, so 26 is a term.
		

Crossrefs

Programs

  • Mathematica
    rootsn7 = Flatten[Position[Table[Floor[Tan[-n]], {n, 1, 10^7}], 1]];
    difn7 = Differences[rootsn7];
    ny = {}; Do[
    If[Table[difn7[[i]], {i, 1, n}] == Reverse[Table[difn7[[i]], {i, 1, n}]],
      AppendTo[ny, n]], {n, 1, Length[difn7]}]
    ny
Showing 1-2 of 2 results.