login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A309709 Number of binary digits that change when n is multiplied by 4. 1
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, 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, 4, 4, 6, 6, 4, 6, 4, 6, 6, 6, 6, 6, 2, 4, 4, 6, 2, 2, 4, 4 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
All terms are even.
LINKS
FORMULA
a(n) = A000120(A048725(n)). - Antti Karttunen, Aug 22 2019
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
EXAMPLE
00101_2 * 100_2 = 10100_2: 2 bits changed, so a(5) = 2.
MAPLE
a:= n-> add(i, i=Bits[Split](Bits[Xor](n*4, n))):
seq(a(n), n=0..120); # Alois P. Heinz, Aug 23 2019
MATHEMATICA
a[n_] := Total@ IntegerDigits[BitXor[n, 4 n], 2]; Array[a, 88, 0] (* Giovanni Resta, Sep 19 2019 *)
PROG
(PARI) A309709(n) = hammingweight(bitxor(n, n<<2)); \\ Antti Karttunen, Aug 22 2019
(Python)
def A309709(n):
s = ""
while n > 0:
s, n = str(n%2)+s, n//2
s, s4, i, j = "00"+s, s+"00", 0, 0
while i < len(s):
if s[i] != s4[i]:
j = j+1
i = i+1
return j # A.H.M. Smeets, Aug 23 2019
CROSSREFS
Cf. also A007302, A069010.
Sequence in context: A087692 A093621 A242734 * A143230 A276604 A072301
KEYWORD
nonn,base,easy
AUTHOR
Ali Sada, Aug 14 2019
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 23 20:33 EDT 2024. Contains 371916 sequences. (Running on oeis4.)