login
Rank of the n-th binary palindrome. The minimal number of iterations A206915(A206915(...A206915(A006995(n))...) such that the result is not a binary palindrome, a(3)=1.
2

%I #18 Nov 14 2018 20:30:06

%S 2,1,1,1,2,1,3,1,2,1,1,1,1,1,4,1,2,1,1,1,3,1,1,1,1,1,2,1,1,1,2,1,2,1,

%T 1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,5,1,2,1,1,1,

%U 1,1,1,1,3,1,1,1,1,1,1,1,1,1,1,1,2,1,1

%N Rank of the n-th binary palindrome. The minimal number of iterations A206915(A206915(...A206915(A006995(n))...) such that the result is not a binary palindrome, a(3)=1.

%C The number of iterations such that A006995(n)=A006995(A006995(A006995(…(A206922(n)…) [For n<>3] .

%H Antti Karttunen, <a href="/A206921/b206921.txt">Table of n, a(n) for n = 1..65537</a>

%F a(n)=k, where k can be determined by the following iteration: set k=0, p(0)=A006995(n). Repeat while A178225(p(k))==1, set k=k+1, p(k)=A206915(p(k-1)) end repeat [for n<>3].

%F Recursion for n<>3:

%F Case 1: a(n)=1, if n is not a binary palindrome;

%F Case 2: a(n)=a(A206915(n))+1, else.

%F Formally: a(n)=if (A178225(n)==0) then 1 else a(A206915(n))+1

%e a(1)=2, since A006995(1)=0=A006995(A006995(2)) [==> 2 iterations; 2 is not a binary palindrome];

%e a(3)=1 by definition;

%e a(4)=1, since A006995(4)=5=A006995(4) [==> 1 iteration; 4 is not a binary palindrome];

%e a(7)=3, since A006995(7)=15=A006995(A006995(A006995(4))) [==> 3 iterations; 4 is not a binary palindrome];

%o /* C program fragment, omitting formal details, n!=3 */

%o k=0;

%o p=A006995(n);

%o while A178225(p)==1

%o {

%o k++;

%o p=A206915(p);

%o }

%o return k;

%o (PARI)

%o up_to = 65537;

%o A178225(n) = (Vecrev(n=binary(n))==n);

%o A206915list(up_to) = { my(v=vector(up_to+1), s=0); for(n=1,up_to+1,s += A178225(n-1); v[n] = s); (v); };

%o v206915 = A206915list(up_to);

%o A206915(n) = v206915[1+n];

%o A206921(n) = if((3==n)||!A178225(n),1,1+A206921(A206915(n))); \\ _Antti Karttunen_, Nov 14 2018

%Y Cf. A006995, A206922, A178225, A206915, A154809.

%K nonn,base

%O 1,1

%A _Hieronymus Fischer_, Mar 12 2012