Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #30 Mar 16 2023 04:52:41
%S 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 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 20,20,14,20,15,15,6,1,7,7,17,7,18,18,23,7,19,19
%N Number of integers in [n .. 2n-1] having the same binary weight as n.
%C Or number of steps it takes to double n, where each step goes to the next larger integer with the same binary weight.
%H Alois P. Heinz, <a href="/A361079/b361079.txt">Table of n, a(n) for n = 0..20000</a>
%F a(n) = |{ k in [n, 2n-1] : A000120(k) = A000120(n) }|.
%F ((x-> A057168(x))^a(n))(n) = 2*n.
%F a(n) = A068076(2n) - A068076(n) = A263017(2n) - A263017(n).
%F a(n) = 1 <=> n in { A000079 }.
%e a(9) = 4: 9 -> 10 -> 12 -> 17 -> 18 or in binary: 1001_2 -> 1010_2 -> 1100_2 -> 10001_2 -> 10010_2.
%p b:= proc(n) option remember; uses Bits; local c, l, k;
%p c, l:= 0, [Split(n)[], 0];
%p for k while l[k]<>1 or l[k+1]<>0 do c:=c+l[k] od;
%p Join([1$c, 0$k-c, 1, l[k+2..-1][]])
%p end:
%p a:= proc(n) option remember; local i, m, t; m, t:=n, 2*n;
%p for i from 0 while m<>t do m:= b(m) od; i
%p end:
%p seq(a(n), n=0..100);
%t 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 (Python)
%o from math import comb
%o def A361079(n):
%o c, k = 0, 1
%o for i,j in enumerate(bin(n)[-1:1:-1]):
%o if j == '1':
%o c += comb(i+1,k)-comb(i,k)
%o k += 1
%o return c # _Chai Wah Wu_, Mar 01 2023
%o (PARI) a(n) = my(w=hammingweight(n)); sum(k=n, 2*n-1, hammingweight(k) == w); \\ _Michel Marcus_, Mar 16 2023
%Y Cf. A000079, A000120, A057168, A068076, A263017.
%K nonn,look,base
%O 0,4
%A _Alois P. Heinz_, Mar 01 2023