cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A144078 a(n) = the number of digits in the binary representation of n that differ from the corresponding digit in the binary reversal of n. (I.e., a(n) = number of 1's in n XOR A030101(n).)

This page as a plain text file.
%I A144078 #16 Oct 07 2018 14:35:21
%S A144078 0,2,0,2,0,2,0,2,0,4,2,4,2,2,0,2,0,4,2,2,0,4,2,4,2,2,0,4,2,2,0,2,0,4,
%T A144078 2,4,2,6,4,4,2,6,4,2,0,4,2,4,2,2,0,6,4,4,2,6,4,4,2,4,2,2,0,2,0,4,2,4,
%U A144078 2,6,4,2,0,4,2,4,2,6,4,4,2,6,4,2,0,4,2,4,2,6,4,2,0,4,2,4,2,2,0,6,4,4,2,4,2
%N A144078 a(n) = the number of digits in the binary representation of n that differ from the corresponding digit in the binary reversal of n. (I.e., a(n) = number of 1's in n XOR A030101(n).)
%C A144078 a(n) + A144079(n) = A070939(n), the number of binary digits in n.
%H A144078 Harvey P. Dale, <a href="/A144078/b144078.txt">Table of n, a(n) for n = 1..1000</a>
%F A144078 From _Rémy Sigrist_, Oct 07 2018: (Start)
%F A144078 a(n) = 0 iff n is a binary palindrome (A006995).
%F A144078 a(A143960(n)) = 2*n (in fact A143960(n) is the least k such that a(k) = 2*n).
%F A144078 (End)
%e A144078 20 in binary is 10100. Compare this with its digit reversal, 00101. XOR each pair of corresponding digits: 1 XOR 0 = 1, 0 XOR 0 = 0, 1 XOR 1 = 0, 0 XOR 0 = 0, 0 XOR 1 = 1. There are two bit pairs that differ, so a(20) = 2.
%p A144078 A144078 := proc(n) local a,dgs,i; a := 0 ; dgs := convert(n,base,2) ; for i from 1 to nops(dgs) do if op(i,dgs)+op(-i,dgs) = 1 then a := a+1 ; fi; od; RETURN(a) ; end: for n from 1 to 240 do printf("%d,",A144078(n)) ; od: # _R. J. Mathar_, Sep 14 2008
%t A144078 brd[n_]:=Module[{idn2=IntegerDigits[n,2]},Count[Transpose[{idn2, Reverse[ idn2]}], _?(#[[1]]!=#[[2]]&)]]; Array[brd,110] (* _Harvey P. Dale_, May 09 2016 *)
%o A144078 (PARI) a(n) = hammingweight(bitxor(n, fromdigits(Vecrev(binary(n)),2))) \\ _Rémy Sigrist_, Oct 07 2018
%Y A144078 Cf. A006995, A030101, A143960, A144079.
%K A144078 base,nonn
%O A144078 1,2
%A A144078 _Leroy Quet_, Sep 09 2008
%E A144078 More terms from _R. J. Mathar_, Sep 14 2008