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.

A044918 Positive integers whose base-2 run lengths form a palindrome.

Original entry on oeis.org

1, 2, 3, 5, 7, 9, 10, 12, 15, 17, 21, 27, 31, 33, 38, 42, 45, 51, 52, 56, 63, 65, 73, 85, 93, 99, 107, 119, 127, 129, 142, 150, 153, 165, 170, 178, 189, 195, 204, 212, 219, 231, 232, 240, 255, 257, 273, 297, 313, 325, 341, 365, 381
Offset: 1

Views

Author

Keywords

Comments

This sequence exactly contains those positive integers in A006995 (positive binary palindromes) together with the terms of A035928 (those positive integers n where reversing the order of the binary digits produces the binary complement of n). - Leroy Quet, Sep 14 2009
Also the indices of the compositions that are palindromic. For the definition of the index of a composition see A298644. For example, 93 is in the sequence since its binary form is 1011101 and the composition [1,1,3,1,1] is palindromic. On the other hand, 132 is not in the sequence since its binary form is 10000100 and the composition [1,4,1,2] is not palindromic. The command c(n) from the Maple program yields the composition having index n. - Emeric Deutsch, Jan 28 2018

Crossrefs

Cf. A006995, A035928. - Leroy Quet, Sep 14 2009
Cf. A298644, A101211. - Emeric Deutsch, Jan 28 2018

Programs

  • Maple
    Runs:=proc(L) local j,r,i,k:j:=1: r[j]:=L[1]: for i from 2 to nops(L) do if L[i]=L[i-1] then r[j]:=r[j], L[i] else j:=j+1: r[j]:=L[i] end if end do: [seq([r[k]],k=1..j)] end proc: RunLengths:=proc(L) map(nops,Runs(L)) end  proc: c:=proc(n) ListTools:-Reverse(convert(n,base,2)): RunLengths(`%`) end proc: A:={}: for n from 1 to 500 do crev(n):=[seq(c(n)[1+ nops(c(n))-j],j=1..nops(c(n)))] od:  for n from 1 to 500 do if c(n)=crev(n) then A:=A union {n} else fi od: A; # most of the Maple program is due to W. Edwin Clark. # Emeric Deutsch, Jan 28 2018
  • Mathematica
    Position[Array[Length /@ Split@ IntegerDigits[#, 2] &, 400], ? PalindromeQ, 1] // Flatten (* _Michael De Vlieger, Jan 28 2018 *)
  • PARI
    ispal(v) = {for(i=1, #v\2, if (v[i] != v[#v-i+1], return(0));); return(1);}
    isok(n) = {b = binary(n); lastb = b[1]; vrun = vector(1); vrun[1] = 1; for (i=2, #b, if (b[i] != lastb, vrun = concat(vrun, 1); lastb = b[i];, vrun[#vrun]++;)); return (ispal(vrun));} \\ Michel Marcus, Jul 10 2013