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.

A361079 Number of integers in [n .. 2n-1] having the same binary weight as n.

This page as a plain text file.
%I A361079 #30 Mar 16 2023 04:52:41
%S A361079 0,1,1,2,1,3,3,3,1,4,4,5,4,6,6,4,1,5,5,8,5,9,9,7,5,10,10,9,10,10,10,5,
%T A361079 1,6,6,12,6,13,13,13,6,14,14,15,14,16,16,9,6,15,15,18,15,19,19,12,15,
%U A361079 20,20,14,20,15,15,6,1,7,7,17,7,18,18,23,7,19,19
%N A361079 Number of integers in [n .. 2n-1] having the same binary weight as n.
%C A361079 Or number of steps it takes to double n, where each step goes to the next larger integer with the same binary weight.
%H A361079 Alois P. Heinz, <a href="/A361079/b361079.txt">Table of n, a(n) for n = 0..20000</a>
%F A361079 a(n) = |{ k in [n, 2n-1] : A000120(k) = A000120(n) }|.
%F A361079 ((x-> A057168(x))^a(n))(n) = 2*n.
%F A361079 a(n) = A068076(2n) - A068076(n) = A263017(2n) - A263017(n).
%F A361079 a(n) = 1 <=> n in { A000079 }.
%e A361079 a(9) = 4: 9 -> 10 -> 12 -> 17 -> 18 or in binary: 1001_2 -> 1010_2 -> 1100_2 -> 10001_2 -> 10010_2.
%p A361079 b:= proc(n) option remember; uses Bits; local c, l, k;
%p A361079       c, l:= 0, [Split(n)[], 0];
%p A361079       for k while l[k]<>1 or l[k+1]<>0 do c:=c+l[k] od;
%p A361079       Join([1$c, 0$k-c, 1, l[k+2..-1][]])
%p A361079     end:
%p A361079 a:= proc(n) option remember; local i, m, t; m, t:=n, 2*n;
%p A361079       for i from 0 while m<>t do m:= b(m) od; i
%p A361079     end:
%p A361079 seq(a(n), n=0..100);
%t A361079 f[n_] := f[n] = DigitCount[n, 2, 1]; a[n_] := Count[ Array[f, n, n], f[n]]; Array[a, 75, 0] (* _Robert G. Wilson v_, Mar 15 2023 *)
%o A361079 (Python)
%o A361079 from math import comb
%o A361079 def A361079(n):
%o A361079     c, k = 0, 1
%o A361079     for i,j in enumerate(bin(n)[-1:1:-1]):
%o A361079         if j == '1':
%o A361079             c += comb(i+1,k)-comb(i,k)
%o A361079             k += 1
%o A361079     return c # _Chai Wah Wu_, Mar 01 2023
%o A361079 (PARI) a(n) = my(w=hammingweight(n)); sum(k=n, 2*n-1, hammingweight(k) == w); \\ _Michel Marcus_, Mar 16 2023
%Y A361079 Cf. A000079, A000120, A057168, A068076, A263017.
%K A361079 nonn,look,base
%O A361079 0,4
%A A361079 _Alois P. Heinz_, Mar 01 2023