%I #43 Oct 02 2017 18:19:20
%S 1,1,2,1,4,5,2,1,8,3,10,6,4,5,2,1,16,3,6,5,20,3,12,10,8,9,10,6,4,5,2,
%T 1,32,3,6,5,12,3,10,9,40,11,6,5,24,3,20,18,16,7,18,17,20,12,12,10,8,9,
%U 10,6,4,5,2,1,64,3,6,5,12,3,10,9,24,11,6,5,20,3,18,17,80,7,22,14,12,13,10,9,48
%N a(n) is the least positive k such that the Hamming weight of k equals the Hamming weight of k + n.
%C Inspired by A292849.
%C The Hamming weight of a number n is given by A000120(n).
%C Let b(n) be the smallest t such that a(t) = n. Initial values of b(n) are 0, 2, 9, 4, 5, 11, 49, 8, 25, 10, 41, 22, 85, 83, 225, 16, 51, 47, 177, 20, ... See the logarithmic line graph of first 10^3 terms of b(n) sequence in Links section.
%C Apparently, n = a(n) iff n belongs to A094958. - _Rémy Sigrist_, Oct 02 2017
%H Rémy Sigrist, <a href="/A292895/b292895.txt">Table of n, a(n) for n = 0..16384</a>
%H Altug Alkan, <a href="/A292895/a292895_1.png">A logarithmic scatterplot of a(n) for n <= 10^6</a>
%H Altug Alkan, <a href="/A292895/a292895_2.png">A logarithmic line graph of b(n) for n <= 10^3</a>
%F a(n) <= n for n >= 1.
%F a(2*n) = 2*a(n) for n >= 1.
%F a(2^m) = 2^m and a(5*2^m) = 5*2^m for m >= 0.
%F a(2^m - 1) = 1 for m >= 0.
%F a(2^m + 1) = 3 and a(2^m - 3) = 5 for m >= 3.
%F a(2^m + 3) = 5 for m >= 4.
%F a((2^m - 1)^2) = 2^m - 1 for m >= 1.
%F a(2^(m + 2) + 2^m - 1) = 2^m + 1 m >= 1.
%F a((2^m + 1)^2) = 7 for m >= 3.
%e a(49) = 7 since A000120(7) = A000120(7 + 49) and 7 is the least number with this property.
%p N:= 1000: # to get all terms before the first where n+a(n)>N
%p H:= Array(0..N, t -> convert(convert(t,base,2),`+`)):
%p f:= proc(n) local k;
%p for k from 1 to N-n do
%p if H[k]=H[k+n] then return k fi
%p od:
%p 0
%p end proc:
%p R:= NULL:
%p for n from 0 do
%p v:= f(n);
%p if v = 0 then break fi;
%p R:= R, v;
%p od:
%p R; # _Robert Israel_, Sep 27 2017
%t h[n_] := First@ DigitCount[n, 2]; a[n_] := Block[{k=1}, While[h[k] != h[k + n], k++]; k]; Array[a, 90] (* _Giovanni Resta_, Sep 28 2017 *)
%o (PARI) a(n) = {my(k=1); while ((hammingweight(k)) != hammingweight(n+k), k++); k; }
%Y Cf. A000120, A094958, A292849.
%K nonn,base,easy,look
%O 0,3
%A _Rémy Sigrist_ and _Altug Alkan_, Sep 26 2017