A206921 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, 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, 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, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1
Offset: 1
Examples
a(1)=2, since A006995(1)=0=A006995(A006995(2)) [==> 2 iterations; 2 is not a binary palindrome]; a(3)=1 by definition; a(4)=1, since A006995(4)=5=A006995(4) [==> 1 iteration; 4 is not a binary palindrome]; a(7)=3, since A006995(7)=15=A006995(A006995(A006995(4))) [==> 3 iterations; 4 is not a binary palindrome];
Links
- Antti Karttunen, Table of n, a(n) for n = 1..65537
Programs
-
C
/* C program fragment, omitting formal details, n!=3 */ k=0; p=A006995(n); while A178225(p)==1 { k++; p=A206915(p); } return k;
-
PARI
up_to = 65537; A178225(n) = (Vecrev(n=binary(n))==n); 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); }; v206915 = A206915list(up_to); A206915(n) = v206915[1+n]; A206921(n) = if((3==n)||!A178225(n),1,1+A206921(A206915(n))); \\ Antti Karttunen, Nov 14 2018
Comments