OFFSET
0,3
COMMENTS
Write b(k) as the first k+1 binary digits of n, and write c(k) as the last k+1 binary digits of n, for k=0..m where 2^m <= n < 2^(m+1). Set d(k) = 1 if b(k) = c(k) and d(k) = 0 otherwise. Then d(k) forms the binary digits of a(n): a(n) = Sum_{k=0..m} d(k)*2^k.
LINKS
Paul D. Hanna, Table of n, a(n) for n = 0..1024
EXAMPLE
n = 27 (in base 10) = 11011 (in base 2)
b(k) : 1 ; 11; 110; 1101; 11011
c(k) : 1 ; 11; 011; 1011; 11011
d(k) : 1 ; 1; 0; 0; 1
a(27) = 10011 (in base 2) = 19.
PROG
(PARI) {a(n)=local(B, m, b, c, d); B=binary(n); m=#B; d=vector(m); for(k=1, m, b=vector(k, j, B[j]); c=vector(k, j, B[m-k+j]); if(b==c, d[k]=1, d[k]=0)); subst(truncate(Ser(d)), x, 2)}
CROSSREFS
KEYWORD
nonn
AUTHOR
Philippe Deléham, Nov 16 2011
STATUS
approved