login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = minimal number of 0's that must be changed to 1's in the binary expansion of the n-th prime in order to make it into a palindrome.
2

%I #23 Nov 13 2023 17:54:07

%S 1,0,0,0,1,1,0,1,1,1,0,1,1,2,1,2,1,1,1,2,0,2,2,1,1,2,1,0,2,2,0,1,1,2,

%T 2,3,1,2,1,1,3,1,1,1,2,1,1,1,1,1,3,1,3,1,0,2,2,3,1,1,2,2,2,3,0,1,3,1,

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

%N a(n) = minimal number of 0's that must be changed to 1's in the binary expansion of the n-th prime in order to make it into a palindrome.

%H Paolo Xausa, <a href="/A144477/b144477.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) is half the Hamming distance between the binary expansion of prime(n) and its reversal.

%e a(5) = 1 since prime(5) = 11 = 1011_2 becomes a palindrome if we change the third bit to 0.

%t A144477[n_]:=With[{p=IntegerDigits[Prime[n],2]},HammingDistance[p,Reverse[p]]/2];Array[A144477,100] (* _Paolo Xausa_, Nov 13 2023 *)

%o (PARI)

%o HD(p)=

%o {

%o v=binary(p); H=0; j=#v;

%o for(k=1,#v, H+=abs(v[k]-v[j]); j--);

%o return(H)

%o };

%o for(n=1,100, p=prime(n); an=HD(p)/2; print1(an,", "))

%Y Subsequence of A037888.

%K nonn,base

%O 1,14

%A _Washington Bomfim_, Jan 15 2011, following a suggestion from _Joerg Arndt_.

%E Edited by _N. J. A. Sloane_, Apr 23 2020 at the suggestion of _Harvey P. Dale_