login
A144477
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
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, 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, 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
OFFSET
1,14
FORMULA
a(n) is half the Hamming distance between the binary expansion of prime(n) and its reversal.
EXAMPLE
a(5) = 1 since prime(5) = 11 = 1011_2 becomes a palindrome if we change the third bit to 0.
MATHEMATICA
A144477[n_]:=With[{p=IntegerDigits[Prime[n], 2]}, HammingDistance[p, Reverse[p]]/2]; Array[A144477, 100] (* Paolo Xausa, Nov 13 2023 *)
PROG
(PARI)
HD(p)=
{
v=binary(p); H=0; j=#v;
for(k=1, #v, H+=abs(v[k]-v[j]); j--);
return(H)
};
for(n=1, 100, p=prime(n); an=HD(p)/2; print1(an, ", "))
CROSSREFS
Subsequence of A037888.
Sequence in context: A159847 A327489 A257886 * A106345 A319395 A374462
KEYWORD
nonn,base
AUTHOR
Washington Bomfim, Jan 15 2011, following a suggestion from Joerg Arndt
EXTENSIONS
Edited by N. J. A. Sloane, Apr 23 2020 at the suggestion of Harvey P. Dale
STATUS
approved