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.

A206923 Number of bisections of the n-th binary palindrome bit pattern until the result is not palindromic.

Original entry on oeis.org

1, 1, 2, 1, 3, 1, 3, 1, 2, 1, 4, 1, 2, 1, 4, 1, 2, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 5, 1, 2, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 5, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1
Offset: 1

Views

Author

Hieronymus Fischer, Mar 12 2012

Keywords

Comments

Let k=1, p(1)=A006995(n) and m(1)=number of bits in p(1); if p(k) is a binary palindrome > 1 then iterate k=k+1, m(k)=floor((m(k-1)+1)/2), p(k)=leftmost m(k) bits of p(k-1); else set a(n)=k endif.

Examples

			a(1)=a(2)=1, since A006995(1)=0 and A006995(2)=1;
a(5)=3, since A006995(5)=7=111_2 and so the iteration is 11==>11==>1;
a(9)=2, since A006995(9)=21=10101_2 and so the iteration is 10101==>101;
a(13)=2, since A006995(13)=45=101101_2 and so the iteration is 101101==>101;
a(15)=4, since A006995(15)=63=111111_2 and so the iteration is 111111==>111==>11==>1;
a(37)=3, since A006995(37)=341=101010101_2 and so the iteration is 101010101==>10101==>101;
		

Crossrefs

Programs

  • C
    /* quasi-C program fragment, omitting formal details, n>1 */
    p=n;
    p1=n+1;
    k=0;
    while (A178225(p)==1) && (p != p1)
    {
      p1=p;
      k++;
      m=int(log(p)/log(2));
      p=int(p/2^int((m+1)/2));
    }
    return k;

Formula

Recursion: define f(x)=floor(A006995(x)/2^floor(floor(log_2(A006995(x))+1)/2)), for x=1,2,3,...
Case 1: a(n)=1+a(A206915(f(n))), if f(n) is a binary palindrome;
Case 2: a(n)=1, else.
Formally: a(n)=if (A178225(f(n))==1) then a(A206915(f(n)))+1 else 1.