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.

A309709 Number of binary digits that change when n is multiplied by 4.

This page as a plain text file.
%I A309709 #42 Sep 20 2019 03:54:53
%S A309709 0,2,2,4,2,2,4,4,2,4,2,4,4,4,4,4,2,4,4,6,2,2,4,4,4,6,4,6,4,4,4,4,2,4,
%T A309709 4,6,4,4,6,6,2,4,2,4,4,4,4,4,4,6,6,8,4,4,6,6,4,6,4,6,4,4,4,4,2,4,4,6,
%U A309709 4,4,6,6,4,6,4,6,6,6,6,6,2,4,4,6,2,2,4,4
%N A309709 Number of binary digits that change when n is multiplied by 4.
%C A309709 All terms are even.
%H A309709 David A. Corneth, <a href="/A309709/b309709.txt">Table of n, a(n) for n = 0..9999</a>
%H A309709 Joerg Arndt, <a href="https://www.jjj.de/fxt/fxtbook.pdf">Matters Computational (The Fxtbook)</a>
%H A309709 <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>
%F A309709 a(n) = A000120(A048725(n)). - _Antti Karttunen_, Aug 22 2019
%F A309709 a(A112627(n)) = 2*n and A112627(n) is the first position where 2*n occurs in this sequence. - _David A. Corneth_, Sep 19 2019
%e A309709 00101_2 * 100_2 = 10100_2: 2 bits changed, so a(5) = 2.
%p A309709 a:= n-> add(i, i=Bits[Split](Bits[Xor](n*4,n))):
%p A309709 seq(a(n), n=0..120);  # _Alois P. Heinz_, Aug 23 2019
%t A309709 a[n_] := Total@ IntegerDigits[BitXor[n, 4 n], 2]; Array[a, 88, 0] (* _Giovanni Resta_, Sep 19 2019 *)
%o A309709 (PARI) A309709(n) = hammingweight(bitxor(n, n<<2)); \\ _Antti Karttunen_, Aug 22 2019
%o A309709 (Python)
%o A309709 def A309709(n):
%o A309709     s = ""
%o A309709     while n > 0:
%o A309709         s, n = str(n%2)+s,n//2
%o A309709     s, s4, i, j = "00"+s, s+"00", 0, 0
%o A309709     while i < len(s):
%o A309709         if s[i] != s4[i]:
%o A309709             j = j+1
%o A309709         i = i+1
%o A309709     return j # _A.H.M. Smeets_, Aug 23 2019
%Y A309709 Cf. A000120, A048725, A112627.
%Y A309709 Cf. also A007302, A069010.
%K A309709 nonn,base,easy
%O A309709 0,2
%A A309709 _Ali Sada_, Aug 14 2019